in reply to Re^2: Avoiding if/else knots
in thread Avoiding if/else knots

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]->();