%functions = ( '?' => 0, 'HELLO' => sub { print "Hello, world.\n" }, 'HELP' => sub { print "Type 'hello' or 'goodbye'\n" }, 'GOODBYE' => sub { print "Goodbye...\n"; exit(0) } ); # have to initialize this outside declaration of %functions $functions{'?'} = $functions{'HELP'}; #### while(<>) { $func = $_; chomp($func); $func = uc($func); if( defined($functions{$func}) ) { ### insert code here to execute function in hash ### } else { print "\"$func\" not defined\n"; } } #### &$functions{$func}; #### my $code; $code = $functions{$func}; &$code;