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!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: (Mis)Understanding <c>grep...eq $_<c>
by Marshall (Canon) on Feb 25, 2009 at 08:22 UTC | |
by ikegami (Patriarch) on Feb 25, 2009 at 13:10 UTC | |
by tye (Sage) on Feb 25, 2009 at 15:27 UTC | |
by ikegami (Patriarch) on Feb 25, 2009 at 16:03 UTC | |
by tye (Sage) on Feb 25, 2009 at 18:27 UTC | |
| |
by Marshall (Canon) on Feb 26, 2009 at 18:59 UTC | |
|
In Section
Seekers of Perl Wisdom