A
Andy
I have a perl script that takes an array and processes the arguments
inside it.
while (<@my_array>) {
print "$_";
if (/new/i) {
@new_array = shift @my_array;
}
}
Now I expect as while loop progresses, the array @my_array shrinks but
the while loop get executed for all the indices in @my_array. Say if I
have 10 elements in my_array, then the while loop is executed 10 times.
There are about six times the 'shift' gets executed but it does not
affect the number of iterations of the while loop.
What can be the workaround for this?
thanks,
Anand.
inside it.
while (<@my_array>) {
print "$_";
if (/new/i) {
@new_array = shift @my_array;
}
}
Now I expect as while loop progresses, the array @my_array shrinks but
the while loop get executed for all the indices in @my_array. Say if I
have 10 elements in my_array, then the while loop is executed 10 times.
There are about six times the 'shift' gets executed but it does not
affect the number of iterations of the while loop.
What can be the workaround for this?
thanks,
Anand.