#!/usr/bin/perl -w use strict; use Parse::RecDescent; # get the input text from stdin my $text = join("", <STDIN>); my $grammar = q { start : number(s) EOF EOF : /^\Z/ number : /ph|fax|cell/i /\d+/ { print $item[2]; } } my $parser = new Parse::RecDescent($grammar) or die; defined $parser->start($text) or print "Bad text\n";