in reply to Unshift and push inside of map operation.
I'd probably use two arrays -- one to be processed, and one of what's already been processed:
my @toprocess = qw (a1 a2 a3 a4 a5); my @processed = (); my $i = 10; # avoid an infinite loop while (my $item = shift @toprocess) { push @toprocess, 'x' ; unshift @processed, 'y' ; push @processed, $item; print "array has ". scalar @toprocess. " items left. This one is +$item\n"; last unless $i--; # break out of infinite loop for this example }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unshift and push inside of map operation.
by ikegami (Patriarch) on Sep 23, 2008 at 04:43 UTC | |
by tye (Sage) on Sep 23, 2008 at 05:08 UTC | |
by JadeNB (Chaplain) on Sep 23, 2008 at 18:17 UTC |