Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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.


Comment on Re: Really Long if/elsif/else blocks

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://690329]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-12-27 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls