Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Pattern matching with qr// and modifiers

by JavaFan (Canon)
on May 05, 2012 at 09:47 UTC ( [id://969031]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Pattern matching with qr// and modifiers
in thread Pattern matching with qr// and modifiers

I find it surprising that adding the modifier back later has no effect, and triggers no warnings. I guess I’ll just have to remember that once a regex has been compiled with qr//, its d, i, m, s, and x settings are thereafter immutable.
Well, isn't that the point of having a compiled regexp? Now, if you compile a regexp, you know exactly what you have. Otherwise, if I have a compiled regexp, I still don't know what it does, because modifiers can be applied. It also means that if you would do something like:
my $pat = gimme_pat(); # Some method returning a qr if ($str =~ /^ $pat $ # Anchor pattern/x) { ... }
will break if $pat uses spaces.

Replies are listed 'Best First'.
Re^4: Pattern matching with qr// and modifiers
by Athanasius (Archbishop) on May 05, 2012 at 10:06 UTC

    Yes, this makes sense; but that “quotes (and possibly compiles)” in perlop is still worrying me. If I use qr// but it only quotes (and doesn’t compile), then, as you say, I still don’t really know what it does, do I?

    Thanks,

    Athanasius <°(((><contra mundum

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-29 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found