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

This has to be a pilot error. I get expected results with various perls from 5.8.0 to 5.8.4.
  • Comment on Re: Is there any way to get at paren matches from qr//

Replies are listed 'Best First'.
Re: Re: Is there any way to get at paren matches from qr//
by nneul (Novice) on May 13, 2004 at 16:06 UTC
    $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
    
      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.
      Uh. Never mind. I see it now. Somehow I lost the qr//. Doh!