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 / 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 |
You want to print the contents of an entire array. How would you do that?
Differentiate use and require?
What?s your favorite module and why?
What are numeric operators in perl?
Explain ivalue?
How many types of variable in perl?
Define dynamic scoping.
how to install a package in perl ????
What are some common methods to all handles in perl?
How would you ensure the re-use and maximum readability of your perl code?
what is Chop & Chomp function does?
Difference between the variables in which chomp function work ?