This way you only have to change the hash as your selection alternatives change.use strict; my %hash=(1=>"Turkey",2=>"Goat",3=>"Fish"); print "choose 1:\n"; for(sort keys %hash){ print "$_=$hash{$_}\n"; } print "Choice: "; my $ans=<STDIN>; chomp $ans; print "Invalid Answer!" unless exists $hash{$ans}; print "You chose $hash{$ans}\n";
In reply to Re: STDIN method?
by insensate
in thread STDIN method?
by vivekvp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |