Using perl's Regexp::Grammars, how do I make a capture dependent on $MATCH?

Posted by Evan Carroll on Stack Overflow See other posts from Stack Overflow or by Evan Carroll
Published on 2010-06-15T19:37:15Z Indexed on 2010/06/15 19:42 UTC
Read the original article Hit count: 278

Filed under:
|

I've got a token like such:

<delim2=((?{ $MATCH{delim} }))>

and what I want to happen is for delim2 to capture and be set to the value of delim. When I run this, delim2 is set, but the capture is never done. I think this is an error in my reasoning: I'm trying to chain this form:

<ALIAS= ( PATTERN )>     Match pattern, save match in $MATCH{ALIAS}

and this form: (?{ MATCH{delim} }) into something like this

<ALIAS= ( (?{MATCH{delim}) )>     Matches the value of $MATCH{delim} save to $MATCH{delim2}

but this simply doesn't seem valid. I can verify my original token works <delim2=((?{ die $MATCH{delim} }))> will die with the value, and, if I hard code it, I get the right capture and everything works <delim2=(')>? So how do I go about achieving sane results, while having a dynamic pattern?

© Stack Overflow or respective owner

Related posts about perl

Related posts about regexp-grammars