in reply to Re: Invoke sub whose name is value of scalar
in thread Invoke sub whose name is value of scalar

I saw the root node's title and the number of replies and without even looking at the content figured people were demonstrating lots of different ways to do dispatch tables. Then actually reading the thread, I saw no dispatch tables at all, until the very last reply, by Erez.

Better late than never :)

If (as I guess from the OP's update) the subs do more than one-line of work, you can still use a dispatch table, but arranged like:

sub foo { ... } sub bar { ... } my %hash = ( foo => \&foo, bar => \&bar, ); $var = "foo"; &{$hash{$var}}(@args);