Perl already has named capture groups as legit syntax, so it would be most
simple to actually use them.

https://perldoc.perl.org/perlre#(?%3CNAME%3Epattern)

header FROM_NAME /^From: "(?<NAME>\w+)/

Good. I thought there was someting there, but I didn't remember the exact syntax and was too lazy to dig it out. Works for me.


... just save the matches it in the rule code
$pms->{captured_values}->{FROM_NAME}->{NAME} = $+{NAME};

Then use it in a rule:

body MATCHER /My name is ${FROM_NAME:NAME}/

Don't nitpick on ${}, could be any similar syntax.  Code adds this rule to
FROM_NAME dependency chain.  When FROM_NAME hits, run MATCHER regex
(obviously first recompile the regexp).

The only nitpick I'd offer is that I'd prefer that the capture tokens be at a single level, like rule names. So you might get:

$pms->{captured_values}->{NAME} = $+{NAME};

Then use it in a rule:

body MATCHER /My name is ${NAME}/

       Loren

Reply via email to