use warnings; use Carp; use Parse::RecDescent; $|=1; my $GlobalConfigMode=q( Interface: ('fa' |'gigabit' |'atm') module '/' slot {print "SUCCESS"} module: /\d+/| slot:/\d+/ | ); my $parser= new Parse::RecDescent($GlobalConfigMode) or croak "Could not create command parser" ; while(){ chomp; if($parser->Interface($_)){ print "$_ \t success\n" ; } else { print "$_ Command not found\n"; } print"------------------\n"; } __DATA__ fa 0/1 atm 0/1 gigabit 0/1 fastethernet co gigabit 01111 fa 0/1 enable gigabit 0/1 disable fastethenet asdf