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 lists and ivalue?
What does file test operators do in perl?
What is the difference between use and require in perl?
How can you create an object of a class in a package?
How can the user execute a long command repeatedly without typing it again and again?
What is automatic error handling in perl?
There are some duplicate entries in an array and you want to remove them. How would you do that?
Which web site will help the student to download the Java mini Project ?
How to count no of occurrence of a unique patterns in perl?
Can any1 tell me 2 write the script using perl script 2 looking at a log file 2 see wheather the test has passed or not.
What is perl push array function?
Explain what is lvalue?