Take this example script: ===================================================== #!/usr/local/bin/perl -w use strict; use Parse::RecDescent;
$::RD_WARN = 1; $::RD_HINT = 1; my $grammar = q { startrule: statement(s) { $return = [EMAIL PROTECTED]; } | { foreach (@{$thisparser->{errors}}) { print("Line $_->[1] of $0:$_->[0]"); } $thisparser->{errors} = undef; } statement: comment | <error: Unknown statement: $text> comment: m{\#(.*?)\n} }; my $text = "# comment adsfasdf, asdfsafsd # comment "; my $parser = new Parse::RecDescent($grammar) or die "Bad Grammar"; my $ret = $parser->startrule($text); my @array = @$ret; for ( my $x = 0 ; $x < @array ; $x++ ) { print("line is $array[$x]\n"); } =================================================== The output is: line is # comment It only prints the first line and silently exits after encountering the bad line. If I change $text to be: my $text = "adsfasdf, asdfsafsd # comment # comment "; The output is: Line 1 of test.pl: Unknown statement: adsfasdf, asdfsafsd # comment # comment This is exactly what I want, but I don't get this error if the bad line is in the middle of the $text. What am I doing wrong? Thanks for any help you can give. Jon Hayden