smack has asked for the wisdom of the Perl Monks concerning the following question:
Greetings Fellow Monks,
I have recently found myself with an out of control "if" statement. It started out innocently enough; with 3 conditions. It has grown, however, to 10 conditions (and is going to keep growing). I have tried to use a switch statement, but Switch.PM breaks my entire program just by including it! All the code does is evaluate a variable, and based on the content call a function. My question is: What should I be using if I cannot use a case statement in such a situation? Is there a better module I can use, or coding technique? I can't help but feel this "if" statement is far too big. =)
Best Regards,
smack
I have recently found myself with an out of control "if" statement. It started out innocently enough; with 3 conditions. It has grown, however, to 10 conditions (and is going to keep growing). I have tried to use a switch statement, but Switch.PM breaks my entire program just by including it! All the code does is evaluate a variable, and based on the content call a function. My question is: What should I be using if I cannot use a case statement in such a situation? Is there a better module I can use, or coding technique? I can't help but feel this "if" statement is far too big. =)
Best Regards,
smack
20050521 Edit by broquaint: Changed title from 'Switch.PM'
Back to
Seekers of Perl Wisdom