Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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

by AnomalousMonk (Chancellor)
on Oct 05, 2011 at 06:11 UTC ( #929711=note: print w/replies, xml ) Need Help??

in reply to ${^MATCH} regex special variable(s) and /p regex modifier

Following the replies of JavaFan and lidden, I tried matching against the string 'foo 123 bar' in Strawberries 5.10.1 and 5.12.3. I found that without the /p modifier  /(123)/ and  /\d+/ 'correctly' assigned to all the  ${^MATCH} variables and  /123/ did not. (All these regexes assign as expected when the /p modifier is used.)

I guess the take-away lesson here is toolic's emphasis on the word 'guaranteed' in the documentation: it really does mean what it says. I'm of two minds about submitting a patch request for the docs. On one hand, the current documentation states simply and clearly what is guaranteed and the conditions of the guarantee. On the other hand, I have a compulsion to warn that without the protection of the /p modifier, there are situations in which the  ${^MATCH} variables may seem to work properly without, in fact, doing so reliably; i.e., one may spend the day ambling very enjoyably through the jungle, then suddenly find oneself standing in a ten foot deep hole with a five foot bamboo stake up a very sensitive place. Must think on this.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://929711]
and a kettle whistles...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2018-03-21 02:01 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (263 votes). Check out past polls.