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 is the use of command “use strict”?

1029


What is the different between array and hash in perl programming?

930


Explain a tell function in perl?

964


Which has the highest precedence, List or Terms? Explain?

891


How to add elements in a hash in perl?

926


How to print escaping characters inside a string in perl?

900


What is perl scripting?

945


Define perl scripting?

988


What does undef function in perl?

950


We all know private variables exist in perl. But do private METHODS exist in perl ? Eg ?

2480


How to open and read data files with Perl

1051


what are the two ways to get private values inside a subroutine or block?

943


What is qq (double q)operator in perl?

1018


How do I send e-mail from a Perl/CGI program on a Unix system?

1009


Difference between the variables in which chomp function work ?

1074