artist has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl -w use Parse::RecDescent; $::RD_ERRORS = 1; # Make sure the parser dies when it encounters an er +ror $::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(<DATA>){ chomp; print "Matches: ", $parser->record($_),"\n"; } __DATA__ 1A34 John 3B5 Mary Bill 1+3 Matt Wilma 2x3 Gary
id => 1A34 name => John Matches: 1 id => 3B5 name => Mary Matches: 1 Use of uninitialized value in print at x2.pl line 16, <DATA> line 3. Matches: id => 1+3 name => Matt Matches: 1 Use of uninitialized value in print at x2.pl line 16, <DATA> line 5. Matches: id => 2x3 name => Gary Matches: 1Hi Monks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Capture Spaces
by trs80 (Priest) on Feb 07, 2002 at 21:15 UTC | |
|
Re: Capture Spaces
by runrig (Abbot) on Feb 08, 2002 at 00:42 UTC | |
|
Re: Capture Spaces
by merlyn (Sage) on Feb 07, 2002 at 21:04 UTC | |
by artist (Parson) on Feb 07, 2002 at 22:29 UTC |