RE: Line contination characters - how do I access these variables - SUMMARY
[email protected] ("Orton, Yves") Wed, 26 Jun 2002 18:22:40 +0100
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <71B318898201D311845C0008C75DAD1C06F1E63A@defra1ex2> |
Note that you dont _have_ to use startrule. You can use the name of the rule you wish to start with. Have a second look at Damians example. Yves > -----Original Message----- > From: [email protected] [mailto:[email protected]] > Sent: 26 June 2002 19:19 > To: [email protected] > Subject: RE: Line contination characters - how do I access these > variables - SUMMARY > > > > > This leads to my next question. Since the returned hash > does not have a > > name, how do I access it? Who is it returned to? > > Thank to proding from Yves, I figured it out: > > my $parser = Parse::RecDescent->new($grammar); > > my $out = $parser->startrule( $text ); > # before I was calling the parser as: > # $parser->startrule( $text ); > # I was not saving any of the information. > > # Nexted I used Dumper to figure out what format the data was in > print Dumper($out); > > # I found out it was an array and was able to access the hash > print "$out->[1]{comment} \n"; > print "$out->[2]{command} \n"; > > > Thanks again, > > jr >