Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^3: ${^MATCH} regex special variable(s) and /p regex modifier

by JavaFan (Canon)
on Oct 04, 2011 at 11:15 UTC ( [id://929512] : note . print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    $ perl -wE 'my $s = "foo bar"; $s =~ /(bar)/; say ${^PREMATCH}'
    Use of uninitialized value $^PREMATCH in say at -e line 1.
  2. or download this
    $ perl -Mre=debug -wE 'my $s = "foo bar"; $s =~ /bar/;'
    Compiling REx "bar"
    Match successful!
    Freeing REx: "(bar)"