in reply to Avoiding if/else knots II
I still don't want to have to construct a table with around, say, 60 combinations of which only around, say, 20 are distinct.I'd also take the approach to normalize the 60 posibilities, i.e. coerce them into unique keys in the dispatchtable, with e.g.
and finally dispatch via a table$key = 'default'; $case =~ s/$reg2// && ($key = 'a'); $case =~ s/$reg1// and do { whatever(); $key = 'b' }; ...
$dispatch{$key}->(@args);
Can anyone see any possible drawbacks to this approach?
Not yet, since neither context nor implementation are visible...
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Avoiding if/else knots II
by Skeeve (Parson) on Aug 30, 2006 at 09:32 UTC | |
by shmem (Chancellor) on Aug 30, 2006 at 09:43 UTC | |
by Skeeve (Parson) on Aug 30, 2006 at 10:09 UTC | |
by shmem (Chancellor) on Aug 30, 2006 at 12:44 UTC | |
by Skeeve (Parson) on Aug 30, 2006 at 20:17 UTC |