in reply to Re^3: Processing a dynamic array
in thread Processing a dynamic array

Hey, i have been trying what pg has recommended but it doesn't seem to work. I have added
my $first = shift @links; push @links, $first / 2 if (!($first % 2));
at the end my loop and obviously it gives me the error Argument "http://www.perlmonks.com/" isn't numeric in modulus (%) which makes sense. Then i try just putting
my $first = shift @links; push @links, $first;
at the end of my code but that doesn't seem to work either.

The way i see it, when we shift $first from an array and add it to the end of the array doesn't that mean that $first will be processed again after all the current elements are processed, when we reach that again? I might have the wrong idea for this so could someone please explain? Thanks in advance P.S: The "Argument "http://www.perlmonks.com/" isn't numeric in modulus (%)" is only for reference i havent used the perlmonks website in my loop!!

Replies are listed 'Best First'.
Re^5: Processing a dynamic array
by pg (Canon) on Oct 29, 2005 at 23:29 UTC

    That was just my way of easily simulates a growing array. In my simulation code, array elements are numbers. If you copy and paste my code without understanding it and much thinking, and start to divide an URL by 2, Perl obviously does not like it.

    You need to go back to my original reply, and understand my point, as well as other replies (from other monks).