Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

my @array=('data1','data2'); my @array1=('data1','data2');
my ($i,$k);
$i=7;
$k=7;

while($i){
$array [++$#array] = 'ree';
$i--; print "@array";
}

while($k){
push(@array1,'ree');
$k--;
print "@array1";
}


Are these two while loop are doing the same functionality ?
What may be the difference?

Answer Posted / guest

The above two while loops are used to add the elements into
the end of the array.
But in first while loop we are manually getting the index of
the last element in the array then we are storing the
element into next index.

But push internally performing that operation.
And the push() has some advantages also.

Using push we can add multiple items into an array in a
single instance.
But this is not possible in the fist while loop.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does cgi program store?

853


Define say() function in perl?

904


Write a program to decode the data in the form using cgi programming

987


What is chomp() operator/function?

997


How to determine strings length in perl?

905


What is perl I used for?

905


Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?

921


You want to concatenate strings with perl. How would you do that?

822


What is the purpose of goto expr statement?

837


What is the use of strict?

866


What does undef function in perl?

885


How are parameters passed to subroutines in perl?

890


What is the difference between perl array and perl hash?

978


“Perl regular expressions match the longest string possible”. What is the name of this match?

895


How do I sort a hash by the hash value?

870