diff options
author | Karl Williamson <public@khwilliamson.com> | 2010-08-18 23:48:16 -0600 |
---|---|---|
committer | Florian Ragwitz <rafl@debian.org> | 2010-09-20 08:13:30 +0200 |
commit | fb85c0447bf1d343a9b4d4d7075184aeb4c9ae46 (patch) | |
tree | 47c8406e939af312e69568c7a9ced9ec7d3529ed /lib | |
parent | 5c3fa2e7f75bb4370f758b363cec53992c7fd20a (diff) | |
download | perl-fb85c0447bf1d343a9b4d4d7075184aeb4c9ae46.tar.gz |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Dumpvalue.t | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Dumpvalue.t b/lib/Dumpvalue.t index 8eb70a34b8..6570e38a2e 100644 --- a/lib/Dumpvalue.t +++ b/lib/Dumpvalue.t @@ -130,7 +130,7 @@ is( $out->read, '', 'unwrap ignored glob on first try'); $d->unwrap(*FOO); is( $out->read, "*DUMPED_GLOB*\n", 'unwrap worked on glob'); $d->unwrap(qr/foo(.+)/); -is( $out->read, "-> qr/(?-xism:foo(.+))/\n", 'unwrap worked on Regexp' ); +is( $out->read, "-> qr/(?^:foo(.+))/\n", 'unwrap worked on Regexp' ); $d->unwrap( sub {} ); like( $out->read, qr/^-> &CODE/, 'unwrap worked on sub ref' ); |