P is for Practical | |
PerlMonks |
Re^3: Regular Expressions questionby Lotus1 (Vicar) |
on Oct 30, 2012 at 03:24 UTC ( [id://1001449]=note: print w/replies, xml ) | Need Help?? |
my @check = grep { chomp $_; $_ } <DATA>; Map should be used for this not grep. Consider the following.
The output is: >>line1 line3<<Grep looks at the value the block returns and if true it returns $_. Map is used to do something to each element and pass along the result from each. To me it is clearer and simpler to do this:
In Section
Seekers of Perl Wisdom
|
|