On 2014-03-04 00:35, shawn wilson wrote:
So, when I do this:
my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0];
I get a full line and not just the capture:
# ARIN WHOIS data and services are subject to the Terms of Use
First understand what you coded:
grep() is a filter: it only passes all elements for which the expression
is true.
Your expression is a a "regular expression", and that it has 2 capturing
groups is not relevant.
When I do this:
my $src = (grep {s/.*(ARIN|APNIC).*(\n)?/$1/} @ret)[0];
I get just the match but it also alters the array
That is just a crazy thing to do.
In this way you can both filter and capture:
my @filtered = map { /(.*\b(?:ARIN|APNIC)\b.*)/ ? $1 : () } @ret;
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/