use Parse::RecDescent; my $grammar = <<'__EOI__'; parse: { # Create error message. my $msg = 'FOO!'; # Create error. push(@{$thisparser->{errors}}, [ $msg, $thisline ]) unless $_noactions; # Fail the action. undef; } __EOI__ my $parser = Parse::RecDescent->new($grammar) or die("Bad grammar\n"); $parser->parse('');