Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: Regex's, parentheses, and the mysterious ( ??{ } ) operator

by Clovis_Sangrail (Beadle)
on Jul 12, 2013 at 16:05 UTC ( #1044012=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Regex's, parentheses, and the mysterious ( ??{ } ) operator
in thread Regex's, parentheses, and the mysterious ( ??{ } ) operator

"... our = our"

Yes, I am familiar with the reflexive property of equality. (For all X, X == X.) Can you be a little less enigmatic? Are you saying I cannot use the "our" scope? When I used "my" I created an entirely separate $paren and broke the recursion, and because I have "use strict" I cannot leave the variable undeclared. Perhaps I just cannot use "use strict"?


Comment on Re^4: Regex's, parentheses, and the mysterious ( ??{ } ) operator
Replies are listed 'Best First'.
Re^5: Regex's, parentheses, and the mysterious ( ??{ } ) operator
by AnomalousMonk (Abbot) on Jul 12, 2013 at 18:00 UTC
    ... our is our

    I think Anonymonk is concerned about the second appearance of  our $re within the  (??{ our $re }) regex subexpression. Although somewhat unfamiliar, I think this is kosher because our acts as a declaration of a package variable and  $re needs to be declared or pre-declared somehow to be referenced within the regex under full strictures. The following variations work identically with strictures (note no capturing groups within $re):

    >perl -wMstrict -le "my $s = 'x(y) (a(b)) ()() q (a(b)c()(d(e(f)g))h) q'; ;; our $r3; $r3 = qr{ \( (?: [^()]+ | (??{ $r3 }) )* \) }xms; ;; my @p = $s =~ m{ $r3 }xmsg; print qq{'$_'} for @p; print '--------'; ;; $s =~ m{ ($r3) [^()]* ($r3) }xms; print qq{1 '$1' 2 '$2'}; print '--------'; " '(y)' '(a(b))' '()' '()' '(a(b)c()(d(e(f)g))h)' -------- 1 '(y)' 2 '(a(b))' --------

    And the OPed:

    our $r3 = qr{ ... (??{ our $r3 }) ... }xms;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1044012]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (17)
As of 2015-07-29 19:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (267 votes), past polls