in reply to calling a function as a value from a hash
for a one-off, or where I was using it a lot, for most code I'd do something along the lines of naikonta's later suggestion, only with some correspondence between the names, as in$op_map{$op_choice}->(@args);
This separates the lookup from the invocation, so the invocation is easier to see. It also makes adding a default function easier, as naikonta already showed.my $op = $op_map{$op_choice}; $op->(@args);
|
|---|