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 |
How to turn on Perl warnings? Why is that important?
What is q (single q) operator in perl?
Write a program that explains the symbolic table clearly.
Write a cgi program to show the header part?
What is a chop() function in perl?
how to install a package in perl ????
What is v-strings?
what is the function that is used to identify how many characters are there in a string?
What is the purpose of “_file_ literal” and “_line_ literal” in perl?
What are the characteristics of a project that is well suited to Perl?
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?
Which operator in perl is used for the concatenation of two strings?