Thanks to jwkrahn for the reply.
Ok, perl 5.10.1 gives me: (?-xism:fox.+?jumps).
Under perl 5.14.2 I get: (?^:fox.+?jumps). In perlre: Extended Patterns, this is explained as follows:
Starting in Perl 5.14, a "^" (caret or circumflex accent) immediately after the "?" is a shorthand equivalent to d-imsx.... The caret tells Perl that this cluster doesn't inherit the flags of any surrounding pattern, but uses the system defaults (d-imsx), modified by any flags specified.So, in both cases qr// compiles $regex with the 's' modifier turned off.
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.
By the way, perlop: Regexp Quote Like Operators says of qr//:
This operator quotes (and possibly compiles) its STRING as a regular expression.Why “and possibly compiles”? Under what circumstances does qr// quote rather than compile, and what difference would this make?
Thanks,
Athanasius <°(((>< contra mundum
In reply to Re^2: Pattern matching with qr// and modifiers
by Athanasius
in thread Pattern matching with qr// and modifiers
by Athanasius
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |