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 |
Which has highest precedence in between list and terms? Explain?
What are the steps involved in configuring a server using cgi programming?
Explain a tell function in perl?
How do I pass a command line argument in perl?
Differentiate use and require?
What does `$result = f() .. g()' really return?
I have created a CGI-based page,after entering all the values in to the fields, How to get the output on the web browser using Perl
Why Perl aliases are considered to be faster than references?
Explain returning values from subroutines?
Write a program that shows the distinction between child and parent process?
What is caller function in perl?
I have one question regarding to eval function. I know eval function is use for error checking but I am not able to understand below line. eval \'exec perl -S $0 ${1+\"$@\"}\' if 0; $0 for script name $@ set if error occur