[perl #112604] perlre man page contains suspect example of recursion
authorRonald J Kimball <rjk@tamias.net>
Thu, 24 May 2012 01:17:16 +0000 (18:17 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 24 May 2012 01:18:05 +0000 (18:18 -0700)
Jim Avera wrote:
> This seems incorrect because the \s++ eats all white space without
> backtracking, preventing the following \s+ from matching.
> Thus the pattern always fails for any input.

It should be \s+ \+ \s+

pod/perlre.pod

index 9c5c3ad..b4bb45e 100644 (file)
@@ -1453,7 +1453,7 @@ easier to embed recursive patterns inside of a C<qr//> construct
 for later use:
 
     my $parens = qr/(\((?:[^()]++|(?-1))*+\))/;
-    if (/foo $parens \s+ + \s+ bar $parens/x) {
+    if (/foo $parens \s+ \+ \s+ bar $parens/x) {
        # do something here...
     }