Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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

by AnomalousMonk (Canon)
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.

Comment on Re: ${^MATCH} regex special variable(s) and /p regex modifier
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://929711]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2016-05-31 16:55 GMT
Find Nodes?
    Voting Booth?