in reply to Best option for "switch/case" functionality?
A hash of coderefs is perfect if your cases are all constants, but if you want something that is closer to Switch or given/when, without the headaches, take a look at Dan Brook's Switch::Perlish which allows (for example) a coderef against a hash, or a regex against an array, and many more combinations; but with clear and sane rules about what each combination does.
It's what given/when with smart matching could have been; but with slightly more cumbersome, but still eminently readable syntax.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best option for "switch/case" functionality?
by choroba (Cardinal) on Jun 27, 2016 at 21:02 UTC | |
by BrowserUk (Patriarch) on Jun 27, 2016 at 21:20 UTC | |
by choroba (Cardinal) on Jun 27, 2016 at 21:50 UTC |