in reply to Yet More fun With Array Indices
Also, it's considered dangerous to resize an array while looping over it (Perl-style), and difficult to resive an array while looping over it (index-style).
See? Only increment the index if the element's not being removed. This is why grep() is king. grep() is the True Way.my $i = 0; while ($i < @array) { if (REMOVE) { splice @array, $i, 1 } else { ++$i } }
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|