use warnings; use strict; my %dispatch = ( foo => \&foo, bar => \&bar ); $dispatch{foo}->("here we go!"); my $key = "bar"; $dispatch{$key}->("another message"); sub foo { my $arg = shift; print "foo: $arg\n"; } sub bar { my $arg = shift; print "bar: $arg\n"; } __END__ foo: here we go! bar: another message