In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/8477b9bae3d3ab18dbc355ddaff957d6ccb4c6f7?hp=f5b89942861d4728f63cd3fceeefc6cc2bd6c298>
- Log ----------------------------------------------------------------- commit 8477b9bae3d3ab18dbc355ddaff957d6ccb4c6f7 Author: Karl Williamson <pub...@khwilliamson.com> Date: Thu Sep 23 19:50:34 2010 -0600 perldelta: Give better instructions about (?^...) Avar pointed out that there is an existing API wwhich helps in coping with this ----------------------------------------------------------------------- Summary of changes: pod/perldelta.pod | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 8902b44..3ac058d 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -68,11 +68,22 @@ L</Selected Bug Fixes> section. Default regular expression modifiers are now notated by using C<(?^...)>. Code relying on the old stringification will fail. The purpose of this is so that when new modifiers are added, such code will -not have to change, as the stringification will automatically -incorporate the new modifiers. +not have to change (after this one time), as the stringification will +automatically incorporate the new modifiers. Code that needs to work properly with both old- and new-style regexes -can use something like the following: +can avoid the whole issue by using: + + use re qw(regexp_pattern); + my ($pat, $mods) = regexp_pattern($re_ref); + +where C<$re_ref> is a reference to a compiled regular expression. Upon +return, C<$mods> will be a string containing all the non-default +modifiers used when the regular expression was compiled, and C<$pattern> +the actual pattern. + +If the actual stringification is important, you can use something like +the following: # Accept both old and new-style stringification my $modifiers = (qr/foobar/ =~ /\Q(?^/) ? '^' : '-xism'; -- Perl5 Master Repository