in reply to Re: Is there any way to get at paren matches from qr//
in thread Is there any way to get at paren matches from qr//

$line = "kernel: hda error 22"; $pat = "kernel: (.*?) error"; $re = /$pat/; if ( $line =~ $re ) { print "A: \$1 = $1\n"; if ( $line =~ /$pat/ ) { print "B: \$1 = $1\n"; } }
output:
infinity(77)>./test.pl 
A: $1 = 
B: $1 = hda

Replies are listed 'Best First'.
Re: Re: Re: Is there any way to get at paren matches from qr//
by dave_the_m (Monsignor) on May 13, 2004 at 16:09 UTC
    In your second example you have
    $re = /$pat/;
    when you mean
    $re = qr/$pat/;
    With the qr added, it gives the expected output.
      Yes... working as expected now. Brain/eye/hand communications problems for a bit. Thanks.
Re: Re: Re: Is there any way to get at paren matches from qr//
by nneul (Novice) on May 13, 2004 at 16:09 UTC
    Uh. Never mind. I see it now. Somehow I lost the qr//. Doh!