in reply to Finding specific keyword in Perl

You need a few parentheses in there...

my ($IP) = $line =~ /(\d+\.\d+\.\d+\.\d+)/;
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Finding specific keyword in Perl
by BillKSmith (Monsignor) on Aug 21, 2012 at 17:09 UTC

    Even better, use the Regexp::Common module. Far less chance of false matches.

    use Regexp::Common; my $IP_MATCH = $RE{net}{IPv4}{dec}; my ($IP) =~ $IP_MATCH;
    Bill