http://qs321.pair.com?node_id=745920


in reply to Re: (Mis)Understanding <c>grep...eq $_<c>
in thread (Mis)Understanding grep...eq $_

[grep] searches arrays or lists.

I don't think so. Do you have any reason to believe grep knows anything about arrays?

>perl -le"@a = qw( a b c d ); @b = grep { push(@a,'!') if !$i++; 1 } @ +a; print @b" abcd

Contrast with for which does:

>perl -le"@a = qw( a b c d ); for (@a) { push(@a,'!') if !$i++; push @ +b, $_ } print @b" abcd!