Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
With 5.12.2:
$ perl -wE 'my $s = "foo bar"; $s =~ /(bar)/; say ${^PREMATCH}' foo $ perl -wE 'my $s = "foo bar"; $s =~ /bar/; say ${^PREMATCH}' Use of uninitialized value $^PREMATCH in say at -e line 1. $
Note also the difference in what's going on:
$ perl -Mre=debug -wE 'my $s = "foo bar"; $s =~ /bar/;' Compiling REx "bar" Final program: 1: EXACT <bar> (3) 3: END (0) anchored "bar" at 0 (checking anchored isall) minlen 3 Guessing start of match in sv for REx "bar" against "foo bar" Found anchored substr "bar" at offset 4... Starting position does not contradict /^/m... Guessed: match at offset 4 Freeing REx: "bar" $ perl -Mre=debug -wE 'my $s = "foo bar"; $s =~ /(bar)/;' Compiling REx "(bar)" Final program: 1: OPEN1 (3) 3: EXACT <bar> (5) 5: CLOSE1 (7) 7: END (0) anchored "bar" at 0 (checking anchored) minlen 3 Guessing start of match in sv for REx "(bar)" against "foo bar" Found anchored substr "bar" at offset 4... Starting position does not contradict /^/m... Guessed: match at offset 4 Matching REx "(bar)" against "bar" 4 <foo > <bar> | 1:OPEN1(3) 4 <foo > <bar> | 3:EXACT <bar>(5) 7 <foo bar> <> | 5:CLOSE1(7) 7 <foo bar> <> | 7:END(0) Match successful! Freeing REx: "(bar)" $

In reply to Re^3: ${^MATCH} regex special variable(s) and /p regex modifier by JavaFan
in thread ${^MATCH} regex special variable(s) and /p regex modifier by AnomalousMonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2023-11-28 15:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?