my %dispatch=(FOO => \&_foo, BAR => \&_bar, # ... LAST => \&_last); # And at the end of the script: sub _foo { # ... } sub _bar { # ... } # ...