Hi! I have a newbie question:

I'd like to parse a file line by line...  Line can be terminated by \n or by 
EOF

I do something like this:

===========================
$Parse::RecDescent::skip = '';

my $grammar = q{
  Page: Line(s) {print "Finished! \n"}
  Line: /^.*/   /\n|\Z/  {print "Line: '$item[1]'\n"}
};

my $parser = new Parse::RecDescent($grammar);

my $text = "aaaaa\nbbbbbb\nccccc";

if ($parser->Page($text))
{
  print "Happy!\n"
} else
{
  print "Unhapy :-(\n"
}
===========================

but I get an empty line at the end of the output:

==================
Line: 'aaaaa'
Line: 'bbbbbb'
Line: 'ccccc'
Line: ''
Finished! 
Happy!
===================

I can not understand why it is here...  $::RD_TRACE  = 1; does not give me any 
useful information....

Can you help me by

1. explaining why does it happens

2. telling what is the most right way to do such line by line parsing? (In 
future it should parse something similar to MediaWiki markup). 

Reply via email to