OrangeFlash81 OrangeFlash81 - 3 months ago 40
Perl Question

Perl 6 "grammar" keyword in Perl 5

I recently decided to look at Perl, and when faced with Perl 5 vs 6, I went with 5 due to its maturity and vast support.

However, one of the features of Perl 6 which really intrigued me was the

keyword, allowing one to define a language grammar which can be used to parse complex text. In other languages either an external library or a manual parsing implementation is usually needed for this.

Now that I've settled on Perl 5, is there any rough equivalent to Perl 6's
keyword in Perl 5, built-in or otherwise?


There's no core support, but you can have a look at Parse::RecDescent, Marpa::R2, Regexp::Grammars, or for simpler tasks, just use (DEFINE) in a regex (see perlre).