#!/usr/local/bin/perl -w use Parse::RecDescent; $::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error $::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c. $::RD_HINT = 1; # Give out hints to help fix problems. my $grammer = q{ record: id name id: m[(.{6})] { print "id => $1 " if $1 } name: m[(.*)] { print "name => $1 "; } }; my $parser = Parse::RecDescent->new($grammer); while(){ chomp; print "Matches: ", $parser->record($_),"\n"; } __DATA__ 1A34 John 3B5 Mary Bill 1+3 Matt Wilma 2x3 Gary