I'll take a shot at it since no one else seems to want to. :-) On 6/3/05, BÁRTHÁZI András <[EMAIL PROTECTED]> wrote: > How can I catch the matched elem name, and block content? I'm guessing > that hypotetical variables can be the solution, but it says, that those > variables should have been defined, before I use them, and it's not that > case.
Named subrules have their values stored in the $/ match object under a key of the same name. So, in this case: $foo ~~ m/<block>/; $/<block> will contain the matched block, and $/<block>[1] will contain the block content (i.e. the content of the second capturing group). The working is the same in the case of s///, so you can probably safely use $/ within your &trigger_block and &trigger_elem. Hypothetical variables work like this: my $bar; # not quite sure you need to initialise it; just in case :-) $foo ~~ m/$bar := (bar|baz)/; Now $bar will contain either "bar" or "baz", depending on which one was matched. Hope this is helpful. Corrections are welcome from anyone who spots any mistakes. Aankhen