use Parse::RecDescent; $RD_HINT++; $RD_WARN++; #$RD_TRACE++; my $grammar = q{ Start: Expression(s) /\Z/ Expression: LineNum Print | LineNum Goto | Print: /print/i /\"/ /[\s\w]+/ /\"/ { print "$item[3]\n"; } Goto: /goto/i LineNum { print "Seen a goto line $item[2]\n"; # How do I seek back to line $item[2] of # the input? } LineNum: /\d+/ }; my $parser = new Parse::RecDescent($grammar); undef $/; my $text = <>; $parser->Start($text);