I am searching for multi-line entities in a string, and while I now have working code, I see a quirk in the use of qr// that I did not expect. Here is the example - I have changed the code to look for HTML comments, which illustrates the quirk.
The output is:#! /usr/bin/perl -w use strict; my $html = qq{ blah <!-- comment --> blah <!-- comment --> blah }; print "m: $_\n" for $html =~ /(<!--.*?-->)/sg; my $r = qr/<!--.*?-->/; print "qr: $_\n" for $html =~ /($r)/sg; $r = qr/<!--.*?-->/s; print "qrs: $_\n" for $html =~ /($r)/g;
The quirk is that the s modifier to the regex must be applied to the qr// construct, and may not be applied to the matching later. The g modifier, and the capturing parens may be added, but not the s.m: <!-- comment --> m: <!-- comment --> qr: <!-- comment --> qrs: <!-- comment --> qrs: <!-- comment -->
Do I have this right? Is there sense, order and logic behind not being able to override these qr// modifiers later?
In reply to Unexpected qr// behavior by pbeckingham
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |