Uri Guttman wrote:
Ruud:
Shawn H Corey wrote:
Uri Guttman wrote:

that modifies @ARGV so it is a bad idea. also it bypasses grep's purpose
of filtering a list. and as i posted, map is the correct solution

map is not the correct solution since it does not filter out those which
do not match the pattern.  Only grep can do that.

    my @selected = map { /before(pattern)after/ ? $1 : () } @all;

no need for the ?: as list context will grab $1 or nothing. see my other
post for a working one liner that shows this.

The context changed, because of the "Only grep can do that.".
Each way has it use.

--
Ruud

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to