raghrao has asked for the wisdom of the Perl Monks concerning the following question:
Problem here is that I get different result if I take this value from STDIN .(ie changing the <DATA> in while loop to <STDIN>) Though basic parsing works, if I give additional characters it does not complain.(ie if I give input as <fa 0/1 junkcharcctrasdfadsf> from commandline)use warnings; use Carp; use Parse::RecDescent; $|=1; my $GlobalConfigMode=q( Interface: ('fa' |'gigabit' |'atm') module '/' slot {print "SUCCESS"} + module: /\d+/<commit>|<error?:invalid module > slot:/\d+/<commit> |<error?: error near slot: > ); my $parser= new Parse::RecDescent($GlobalConfigMode) or croak "Could n +ot create command parser" ; while(<DATA>){ 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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Difference between Inputs taken from __DATA__ and STDIN.
by jdporter (Paladin) on Aug 20, 2007 at 12:29 UTC | |
by raghrao (Novice) on Aug 20, 2007 at 13:16 UTC | |
|
Re: Difference between Inputs taken from __DATA__ and STDIN.
by ikegami (Patriarch) on Aug 21, 2007 at 14:23 UTC | |
by raghrao (Novice) on Aug 22, 2007 at 04:55 UTC |