in reply to How do I remove an element from any array while iterating over it in a loop?
I personally think this is ugly and more difficult to follow than:use strict; use warnings; my @arry = qw ( 1 5 5 5 5 2 ); my $i = 0; print "@arry\n"; for ($i = 0; $i < @arry; $i++) { next unless $arry[$i] == 5; splice (@arry, $i, 1); --$i; } print "@arry\n";
but maybe that's just me.use strict; use warnings; my @arry = qw ( 1 5 5 5 5 2 ); my $i = 0; print "@arry\n"; @arry = grep { $_ != 5 } @arry; print "@arry\n";
Ira,
"So... What do all these little arrows mean?"
~unknown
|
|---|