Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Really Long if/elsif/else blocks

by Starky (Chaplain)
on Jun 05, 2008 at 06:06 UTC ( #690329=note: print w/replies, xml ) Need Help??

in reply to Really Long if/elsif/else blocks

If I interpret what you're trying to do correctly, I can't believe no one has pointed you to Parse::RecDescent, a module used for parsing language, whether a programming language or natural language.

You specify a set of rules that define language tokens in what's called a grammar, and then for various components of the grammar, you can identify callbacks (called "actions" in Parse::RecDescent) that specify what should be done when a token is encountered. The module then recursively parses a string based on your grammar and executes any defined actions as tokens are encountered. It's one of the gems of the CPAN.

It's incredibly powerful and would clean up your logic and syntax considerably, though as an incredibly powerful and sophisticated tool, it is also complex.

There is a learning curve, and you'll find that it will take you at least a few days to perhaps a couple of weeks to become comfortable with it and several weeks to inculcate its more esoteric functionality.

But, again, if I interpret what you're trying to do correctly, trust me, the learning curve is well worth it in the long run.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://690329]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2018-03-22 04:42 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (272 votes). Check out past polls.