good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
How to avoid $_ in grepby felipe (Initiate) |
on Nov 13, 2007 at 20:33 UTC ( [id://650588]=perlquestion: print w/replies, xml ) | Need Help?? |
felipe has asked for the wisdom of the Perl Monks concerning the following question: Is there any way to name the $_ variable in grep? For instance, in a foreach loop, we can use $_ like this:
I can avoid by "naming" it, just like this:
Let's go to the point. In a grep statement, I have something like this: my @array_2 = grep {$_->func eq 'TEST'} @array_1;I would really like to name the $_ because I do scripts for biologists and sometimes they modify scripts and they always get lost with $_. Is there any simple way to accomplish this? Thanks in advance.
Back to
Seekers of Perl Wisdom
|
|