%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'};