in reply to Re: Regexp::Common inside Parse::RecDescent
in thread Regexp::Common inside Parse::RecDescent

IMHO, the grammar should definitely be in single quotes since it should not be interpolated in contrast with what Abigail-II says.

You're both wrong. :-)

No just kidding. You are both right. Abigails suggestion would work fine if the $RE expanded before P::RD ever saw it. OTOH, it makes more sense to me to use your approach of use()ing the module inside of the grammar.

And personally I prefer single quoted here docs for my grammars because it avoids the double interpolation problem that can crop up unexpectedly if you arent careful.


---
demerphq

<Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

Replies are listed 'Best First'.
Re: Re: Re: Regexp::Common inside Parse::RecDescent
by Anonymous Monk on Aug 23, 2003 at 17:46 UTC

    I suggest using here-docs for grammars.

    #!perl use warnings; use strict; my $one = q{/\d \\ \/ \\/ / }; my $two = <<'--snip--'; /\d \\ \/ \\/ / --snip-- print "\$one is `$one'\n\$two is `$two'\n"; __END__

    This prints

    $one is `/\d \ \/ \/ / ' $two is `/\d \\ \/ \\/ / '
    which means you needn't escape your backslashes in single-quote here-docs. This can make regexes more readable.