Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: This regex surprised me

by Athanasius (Archbishop)
on Aug 13, 2014 at 17:17 UTC ( [id://1097322]=note: print w/replies, xml ) Need Help??


in reply to This regex surprised me

Printing the pre-compiled regex, I get:

3:05 >perl -wE "my $q = qr/^ab$/; say $q;" (?^u:^ab$) 3:06 >

and from perlre#Extended-Patterns it appears that this is equivalent to (?ud-imsx:^ab$), which explicitly turns off the m modifier throughout of the embeded pattern-match modifier. So adding /m to the regex has no effect, because it is overridden within the (?-m:...) construct inside the regex.

I don’t know how all this worked in earlier versions of Perl, but in recent versions, it seems you have to add the /m modifier when the regex is first constructed using qr//:

my $qre = qr/^ab$/m;

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-26 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found