in reply to menu script

It seems fair enough to me, except for some errors. Check the comments for what was wrong:
#!/usr/bin/perl use strict; use warnings; my %hash = ( # use ampersands, not dollars func => \&func, func2 => \&func2, ); while () { # don't need ampersand to call function menu(); print "select: "; # use my to declare $string chomp(my $string = <STDIN>); # use exists to stop from auto-vivifying hash elements if (exists $hash{$string}) { $hash{$string}->(); } else { print "No such command: $string\n"; sleep 1; system("clear"); } } sub quit { exit; } sub func { print "running func\n"; } sub func2 { print "running func2\n"; } sub menu { while( my ($k, $v) = each %hash) { print "$k "; } print "\n"; } __END__