Is a bad meme in Perl. I know its in the docs (it shouldnt be, even TheDamian has commented on why its a bad idea) but use the unambiguous and easier to read (IMO)my $parser = new Parse::RecDescent($grammar);
and you'll one day save yourself some bizarre debugging. Note that checking the return of a constructor for an object you didnt write is usually a good idea.my $parser = Parse::RecDescent->new($grammar) or die "Failed to create + parser.\n";
The other is that while q§ ... §; sure is funky looking, it is not as suitable as using HereDoc quoting when using PRD and embedded code:
Personally I tend to roll them into one:my $grammar=<<'END_OF_GRAMMAR'; ... END_OF_GRAMMAR my $parser = Parse::RecDescent->new($grammar) or die "Failed to create + parser.\n";
The main reason that <<'END_OF_GRAMMAR' is better is that it is the only normal Perl quoting construct that does not require backslashes or quotes to be escaped. Which in turn can greatly simplify the embedded code that you have in your grammar.my $parser = Parse::RecDescent->new(<<'END_OF_GRAMMAR') or die "Failed + to create parser.\n"; ... END_OF_GRAMMAR
HTH
--- demerphq
my friends call me, usually because I'm late....
In reply to Re: Package variables and Parse::RecDescent
by demerphq
in thread Package variables and Parse::RecDescent
by castaway
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |