Ævar Arnfjörð Bjarmason wrote: > On Sun, Aug 1, 2010 at 19:44, karl williamson <public@khwilliamson.com> wrote: > >> I still don't understand. I had considered interpolation, and it still >> seems to me that the absence of a modifier means use the underlying default >> for the duration of that interpolation, no matter what the outer regex says. >> I don't see a flaw in that thinking. > > It's not an issue if you have a regexp object. But consider this: > > $ perl -E 'my $s = "foo"; my $o = qr/foo/; my $so = "$o"; my $n = > qr/ $s ${o} blah ${so} /i; say $n' > (?i-xsm: foo (?-xism:foo) blah (?-xism:foo) ) > > Even if we didn't dump the default modifiers we could detect the "$o" > case since it's a regexp object, but we wouldn't detect "$so" since > it's a stringified "$o". > I think I understand now, and perhaps it was so obvious to you guys that it didn't get said in a way I can understand. I get the sense that some of the stuff I say about Unicode is so obvious to me that I don't realize it isn't so clear to others without as much background in the topic. What I wasn't realizing is that a clustering parentheses group (?:...) inherits the outer modifiers, unless overridden. Thus in / (?:foo) blah/i the foo is matched case insensitively. If it isn't to be matched with /i, the modifiers must appear as in / (?-i:foo) blah/i Therefore the modifiers must be present always when interpolating. And Ben's suggestion makes sense if there is a substantial body of code out there that relies on stringification never changing.Thread Previous | Thread Next