The 2001 Perl Advent Calendar
[about] | [archives] | [contact] | [home]

On the 25th day of Advent my True Language brought to me..

There's More Than One Way To Do It. And sometimes, just sometimes, that way is not with Perl. It's just easier to do it in another language. Doesn't mean you can't write that language in Perl however.

Parse::RecDescent, is, as the name suggests, a recursive decent parser. This means that it's a module that can be used to make a grammar, a set of rules for breaking up a source file into tokens that the computer can understand. Think of it as a giant regular expression that you can tie code to various sections it matches.

Though defining how to parse some source code, and defining what to do with the results of that coding (either immediately as a interpreter or storing it away in some kind of abstract tree structure for later processing) it's possible to define your own little mini languages. These don't have to be the next Perl - they can be very domain particular. For example you may use Parse::RecDescent to read in your config file. Or parse output from another program.

Armed with this module, and a copy of the

  • Dragon Book
  • , you should be able to do anything. The perfect Perl Christmas present ;-)

  • Parse::ReqDecsent FAQ
  • The Dragon Book