in reply to My favorite looping mechanism in Perl is:
becomes:my @True; for my $Element (@Array){ if ($Element){ push @True, $Element; } }
To get every nth element from a list:my @True = grep {$_} @Array;
I suppose we could argue that grep isn't really intended as a looping mechanism, but map seems to be popular around here, and map is implemented on grep code (internally) so...#(For every fourth element in @List) grep {not ++$i % 4} @List; #(To skip every fifth element) grep {++$i % 5} (1..50)
:-)
Russ
|
---|