I wish to have a hash containing references to sub-functions where I can call those functions dependent upon a user defined variable, I will try and give a simplified example of what I'm trying to do.

my %colors = (
    vim => setup_vim(),
    emacs => setup_emacs(),
)

$colors{$editor}(arg1, arg2, arg3)

where setup_vim() and setup_emacs() would be sub-functions defined later in my file and $editor is a user defined variable (ie vim or emacs). Is this possible? I can't get it working, or find good information on the subject. Thanks.

(Note I have it implemented right now as a working Switch, but I think a hash like the above would make it easier to add new entries to my existing code)

Edit
Report