$myhash{"set time"}=\&settime; $myhash{"show time"}=\&showtime; $myhash{default}=\&error; print "Welcome to nMetrics application monitor\n"; print "Please type in a command\n"; while() { chomp; $res="false"; foreach $k (keys %myhash) { if ( $k eq "$_" ) { &{$myhash{$k}}(); $res="true"; } } if ($res eq "false") { &{$myhash{default}}(); } }