good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Pattern matching with qr// and modifiersby Athanasius (Archbishop) |
on May 05, 2012 at 03:06 UTC ( [id://969011]=perlquestion: print w/replies, xml ) | Need Help?? |
Athanasius has asked for the wisdom of the Perl Monks concerning the following question: Hello Monks, Please see update below.While doing pattern matches using qr// with modifiers added, I ran into behaviour I didn’t expect. The following code, using the 's' modifier to “change "." to match any character whatsoever, even a newline, which normally it would not match.” (perlre: Modifiers)illustrates what I mean:
This is the output I get:
(I’m running DWIM/Strawberry perl 5.14.2 on Vista 32-bit, and I get the same result with perl 5.10.1 on Cygwin.) All the results are as expected, except for A3. I can’t see any (logical) difference between the match patterns in late_mod() and inline_mod(), yet A4 matches (as expected) but A3 does not. I’ve looked at perlop: Regexp Quote Like Operators, also perlfaq6: I'm having trouble matching over more than one line. What's wrong? and How do I match a regular expression that's in a variable? , , but I haven’t found anything that addresses this particular issue. So my questions are:
Since posting, I’ve found How do I apply switches like /i or /g to a qr regexp? which addresses this issue. But I would still appreciate any further information or clarification. Thanks, Athanasius <°(((>< contra mundum
Back to
Seekers of Perl Wisdom
|
|