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.
In reply to Re^3: Deleting specific element in array in FOREACH loop
by ikegami
in thread Deleting specific element in array in FOREACH loop
by awohld
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |