in reply to Best option for "switch/case" functionality?

As brother perlfan has already mentioned, using a hash is a great way to solve this: if the choice has a hash entry (exists), then you call the appropriate anonymous sub; otherwise, you handle the default case.

Alternatively, if you want to handle cases in a specific order (perhaps you want the most likely case first?), you can arrange the list as an array, then just walk through the array.

The great thing about either of these approaches is that the code is really easy to implement, it's very flexible, and I think it's nicely self-documenting.

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.