note
ikegami
<blockquote><p><i>[grep] searches arrays or lists.</i></blockquote>
<p>I don't think so. Do you have any reason to believe grep knows anything about arrays?
<c>
>perl -le"@a = qw( a b c d ); @b = grep { push(@a,'!') if !$i++; 1 } @a; print @b"
abcd
</c>
<p>Contrast with <c>for</c> which does:
<c>
>perl -le"@a = qw( a b c d ); for (@a) { push(@a,'!') if !$i++; push @b, $_ } print @b"
abcd!
</c>
745910
745915