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 |
What does the command "use strict" do and why should you use it?
Which functions in Perl allows you to include a module file or a module and what is the difference between them?
what are the steps involved in reading a cgi script on the server?
Write an expression or perl script to identify the entered ip address is valid or not?
Can inheritance be used in perl? Explain with the help of an example.
Explain tk?
what are the strategies followed for multiple form interaction in cgi programs?
i have a folder called 'error' and in that, i have error log files which are generated by the build, now i want to findout the string 'error' from each log file and that error has to be copied into the another file called 'analysis'. how do you do this in perl?
How can arrays be tied?
What are the advantages of c over Perl?
what are prefix dereferencer and list them out?
What does this symbol mean '->'?