in reply to Re^2: Deleting specific element in array in FOREACH loop
in thread Deleting specific element in array in FOREACH loop
The downside is that
for my $index (reverse 0 .. $#array)
creates a list as large as the array, whereas
for (my $i = $#array; $i > -1; $i--)
and
for (my $i = @array; $i--; )
have no memory cost. That said, it usually doesn't matter.
On the plus side,
for my $index (reverse 0 .. $#array)
could be slower. It is optimized to loop backwards instead of actually calling reverse.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Deleting specific element in array in FOREACH loop
by mreece (Friar) on Sep 15, 2006 at 20:15 UTC | |
by ikegami (Patriarch) on Sep 15, 2006 at 21:47 UTC |