This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add (?^...) regex construct
authorKarl Williamson <public@khwilliamson.com>
Thu, 19 Aug 2010 05:48:16 +0000 (23:48 -0600)
committerFlorian Ragwitz <rafl@debian.org>
Mon, 20 Sep 2010 06:13:30 +0000 (08:13 +0200)
commitfb85c0447bf1d343a9b4d4d7075184aeb4c9ae46
tree47c8406e939af312e69568c7a9ced9ec7d3529ed
parent5c3fa2e7f75bb4370f758b363cec53992c7fd20a
Add (?^...) regex construct

This adds (?^...) to signify to use the default regex modifiers for the
cluster or embedded pattern-match modifier change.  The major purpose of
this is to simplify regex stringification, so that "^" is output in
place of "-xism".  As a result, the stringification will not change in
the future when new regex modifiers are added, so tests, etc. that rely
on a particular stringification will have to change now, but never
again.

Code that needs to work properly with both old- and new-style regexes
can use something like the following:

    # Accept both old and new-style stringification
    my $modifiers = (qr/foobar/ =~ /\Q(?^/) ? '^' : '-xism';

This construct is Ben Morrow's idea.
14 files changed:
dist/Data-Dumper/t/bless.t
ext/Devel-Peek/t/Peek.t
lib/Dumpvalue.t
pod/perldelta.pod
pod/perldiag.pod
pod/perlre.pod
regcomp.c
regexp.h
t/comp/parser.t
t/lib/warnings/regcomp
t/re/pat.t
t/re/pat_re_eval.t
t/re/re.t
t/run/fresh_perl.t