in reply to Simple menu..

with code tags :)

use strict; my %commands = ( "command1" => \&sub1, "command2" => \&sub2, "command3" => \&sub3, "command4" => \&sub4, "command5" => \&sub5, "command6" => \&sub6, "exit" => sub { die "Goodbye" } ); while(1){ print "1. command1\n"; print "2. command2\n"; print "3. command3\n"; print "4. command4\n"; print "5. command5\n"; print "6. command6\n"; print "7. exit\n"; print "\n\n"; print "Please choose an option from the menu above: "; chomp(my $commands = ); if ($commands{my $string}) { $commands{$string}->(); } else { print "No such command: $string\n"; } }

well, I'm not sure where the rest of this is, but if I'd have to guess i'd say the chomp(my $commands = ); and the if ($commands{my $string}) are your problem. The first is a mystery. I'm guessing you wanted something like:

my $commands = <>; chomp $commands;
so you could get user input and then use it to grab a sub from your hash. The second just looks like you got a bit mixed up (as i often do :). You cannot use my inside functions like that. It's its own entity and would need its own line. You could set its value with a function like:
my $this = &that($thing);
But not that way you have it. Also, you'd need to have the variable in the hash key defined before using it - like you use it in the command after the if line.

hope that helps.

-- I'm a solipsist, and so is everyone else. (think about it)