When and why did the output of qr() change?

perl, regex

Solution

It's documented in `perl5140delta`:

Regular Expressions

`(?^...)` construct signifies default modifiers

[...] Stringification of regular expressions now uses this notation. [...]

This change is likely to break code that compares stringified regular expressions with fixed strings containing `?-xism`.

The function `regexp_pattern` can be used to parse the modifiers for normalisation purposes.

Problem

The output of perl's `qr` has changed, apparently sometime between versions 5.10.1 and 5.14.2, and the change is not documented--at least not fully. To demonstrate the change, execute the following one-liner on each version: ``` perl -e 'print qr(foo)is."\n"' ``` Output from perl 5.10.1-17squeeze6 (Debian squeeze): ``` (?-xism:foo) ``` Output from perl 5.14.2-21+deb7u1 (Debian wheezy): ``` (?^:foo) ``` The perl documentation (`perldoc perlop`) says: $rex = qr/my.STRING/is; print $rex; # prints (?si-xm:my.STRING) s/$rex/foo/; which appears to no longer be true: ``` $ perl -e 'print qr/my.STRING/is."\n"' (?^si:my.STRING) ``` I would like to know when this change occurred (which version of Perl, or supporting library or whatever). Some background, in case it's relevant: This change has caused a bunch of unit tests to fail. I need to decide if I should simply update the unit tests to reflect the new format, or make the tests dynamic enough to support both formats, etc. To make an informed decision, I would like to understand why the change took place. Knowing when and where it took place seems like the best place to start in that investigation.

Original source