This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta: Note Perl version of regexp_pattern()
authorKarl Williamson <public@khwilliamson.com>
Fri, 24 Sep 2010 14:46:12 +0000 (08:46 -0600)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 24 Sep 2010 15:26:39 +0000 (08:26 -0700)
perldelta suggests using this, but it didn't come into being until
5.9.5, so cpan modules may not be able to use it.

pod/perldelta.pod

index 288691e..b2d2313 100644 (file)
@@ -72,7 +72,7 @@ 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
 automatically incorporate the new modifiers.
 
 Code that needs to work properly with both old- and new-style regexes
-can avoid the whole issue by using:
+can avoid the whole issue by using (for Perls since 5.9.5):
 
  use re qw(regexp_pattern);
  my ($pat, $mods) = regexp_pattern($re_ref);
 
  use re qw(regexp_pattern);
  my ($pat, $mods) = regexp_pattern($re_ref);
@@ -82,8 +82,8 @@ 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.
 
 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:
+If the actual stringification is important, or older Perls need to be
+supported, you can use something like the following:
 
     # Accept both old and new-style stringification
     my $modifiers = (qr/foobar/ =~ /\Q(?^/) ? '^' : '-xism';
 
     # Accept both old and new-style stringification
     my $modifiers = (qr/foobar/ =~ /\Q(?^/) ? '^' : '-xism';