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 an interpolation in perl?

1044


How to know whether a key exists or not in perl?

1017


what is Perl one liner?

945


If you want to empty an array then how would you do that?

1171


What does init 5 and init 0 do?

1068


Enlist the advantages of using c over perl?

963


Differentiate between arrays and list in perl.

1030


Why we use CGI?

2587


What is the use of -t?

1022


Explain perl. When do you use perl for programming?

916


Which of these is a difference between Perl and C++ ?

1084


Explain the difference between die and exit in perl?

923


How will you declare a variable in perl?

1019


Difference between the variables in which chomp function work ?

1115


Which functions in Perl allows you to include a module file or a module and what is the difference between them?

1092