Don't ask to ask, just ask | |
PerlMonks |
Re: Perl/Unix caseby Elgon (Curate) |
on Oct 22, 2004 at 17:45 UTC ( [id://401593]=note: print w/replies, xml ) | Need Help?? |
Your suggestion was a good one IMHO, or at least very close to being good - look up dispatch tables and/or coderefs in super search and you should find something. They are a useful and elegant way of handling this kind of problem. UPDATE: Look here for a small hint on the use of dispatch tables. Code also added below...
You use the string values of $foo and $bar as keys to the hash, which contains references to subroutines (in this case named, but can be anonymous subs in the hash itself. This is a bit of a rigmarole to go through, but ends up being better to work with than a huge nest of if statements. It is better either to be silent, or to say things of more value than silence. Sooner throw a pearl at hazard than an idle or useless word; and do not say a little in many words, but a great deal in a few. Pythagoras (582 BC - 507 BC)
In Section
Seekers of Perl Wisdom
|
|