OrangeFlash81 OrangeFlash81 - 1 year ago 80
Perl Question

How can I define a parsing grammar 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 (or other functionality for building grammars), built-in or otherwise?

Answer Source

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).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download