in reply to Re^3: Regex's, parentheses, and the mysterious ( ??{ } ) operator
in thread Regex's, parentheses, and the mysterious ( ??{ } ) operator
Ahh! I have deciphered the meaning of your koan. I get a compilation error when I take the "our" out of the middle of the recursive regex:
$ vi p6.pl "p6.pl" 36 lines, 925 characters #!/opt/perl5.16/bin/perl use strict; use warnings; our $paren = qr/ # Need declared variable with use stri +ct. \( ( [^()]+ # Not parens | (??{ $paren }) # Another balanced group (not interpol +ated yet) )* \) /x; # 'x' means ignore whitespace, comment +s. my $stuff = "On the outside now then (we go( in( and in (&stop)(awhile +) ( furthe r ))) but still (here) ) and now (for a while) we are out again."; $stuff =~ /($paren)[^()]*($paren)/; print "----------\n"; print "$stuff\n"; print "----------\n"; "p6.pl" 27 lines, 650 characters $ ./p6.pl Variable "$paren" is not imported at (re_eval 1) line 2. Global symbol "$paren" requires explicit package name at (re_eval 1) l +ine 2. Compilation failed in regexp at ./p6.pl line 14. $
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Regex's, parentheses, and the mysterious ( ??{ } ) operator
by Clovis_Sangrail (Beadle) on Jul 12, 2013 at 16:31 UTC | |
by AnomalousMonk (Archbishop) on Jul 12, 2013 at 18:42 UTC | |
by Clovis_Sangrail (Beadle) on Jul 15, 2013 at 17:08 UTC | |
by AnomalousMonk (Archbishop) on Jul 15, 2013 at 19:24 UTC |