X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlre.pod;h=529c44adf16f28f8c6d9153975631fd5031906f8;hb=197afce1e759b5f0a1885a151064a83b27a7324e;hp=a076d3ad66a8747e1a83a5c3be0d334ce0ba8411;hpb=fdf0a293a88d8a14c42b43c2f82c991c50f7dc39;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlre.pod b/pod/perlre.pod index a076d3a..529c44a 100644 --- a/pod/perlre.pod +++ b/pod/perlre.pod @@ -62,7 +62,7 @@ Extend your pattern's legibility by permitting whitespace and comments. =item p X
X modifier is special in that it can only be enabled,
not disabled, and that its presence anywhere in a pattern has a global
effect. Thus C<(?-p)> and C<(?-p:...)> are meaningless and will warn
@@ -801,8 +766,24 @@ which buffer the captured content will be stored.
/ ( a ) (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
# 1 2 2 3 2 3 4
-Note: as of Perl 5.10.0, branch resets interfere with the contents of
-the C<%+> hash, that holds named captures. Consider using C<%-> instead.
+Be careful when using the branch reset pattern in combination with
+named captures. Named captures are implemented as being aliases to
+numbered buffers holding the captures, and that interferes with the
+implementation of the branch reset pattern. If you are using named
+captures in a branch reset pattern, it's best to use the same names,
+in the same order, in each of the alternations:
+
+ /(?| (? x ) (? y )
+ | (? z ) (? w )) /x
+
+Not doing so may lead to surprises:
+
+ "12" =~ /(?| (? \d+ ) | (? \D+))/x;
+ say $+ {a}; # Prints '12'
+ say $+ {b}; # *Also* prints '12'.
+
+The problem here is that both the buffer named C<< a >> and the buffer
+named C<< b >> are aliases for the buffer belonging to C<< $1 >>.
=item Look-Around Assertions
X