From fb85c0447bf1d343a9b4d4d7075184aeb4c9ae46 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Wed, 18 Aug 2010 23:48:16 -0600 Subject: 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. --- lib/Dumpvalue.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') 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' ); -- cgit v1.2.1