in reply to Re: Parse::RecDescent: autoactions and precompiled grammars
in thread Parse::RecDescent: autoactions and precompiled grammars

Just to confirm (since the docs only mention this working with new and the parent wasn't confident in his answer), here's a working example of $::RD_AUTOACTION being set when Precompile is called:
use Data::Dumper qw( Dumper ); use Parse::RecDescent (); { local $::RD_AUTOACTION = q { [@item] }; Parse::RecDescent->Precompile( 'parse: /a/ /b/ /c/', 'Grammar' ) or die("Bad grammar\n"); } { # Normally, this would be in another file. require Grammar; my $parser = Grammar->new(); print(Dumper($parser->parse('a b c'))); }

outputs

$VAR1 = [ 'parse', 'a', 'b', 'c' ];

If you comment out autoaction, the output is

$VAR1 = 'c';