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 |
Explain which feature of PERL provides code reusability?
How to do comment in perl?
Explain tk?
Write a script to reverse a string without using perl's built in functions?
Explain the default scope of variables in perl?
How do you give functions private variables that retain their values between calls?
how to search a unique pattern in a file by using perl hash map function ??? plz answer me
What does undef function in perl?
Which has the highest precedence, List or Terms? Explain?
Does Perl have reference type?
What happens when you return a reference to a private variable?
How many loop control keywords are there in perl?