When dealing strictly with small positive integers like in your example, an array might be better than a hash.
sub action_1_to_999 { print "1 to 999\n"; } my @dispatch = ( sub { print "Zero\n" }, map { \&action_1_to_999 } ( 1 .. 999 ), sub { print "1e3\n" }, ); $dispatch[0]->(); $dispatch[23]->();
In reply to Re^3: Avoiding if/else knots
by ikegami
in thread Avoiding if/else knots
by loris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |