rshoe has asked for the wisdom of the Perl Monks concerning the following question:
I know the problem is where I need to get the value, but I am not sure how to fix it. If any one can help me I would appreciate it. Thank you for your time. Randy### create a hash my %fruit_num = ( apple => 3, bananas => 1, oranges => 2, ); ### promp the user to enter a key ### use the input to display the value with that key. print "Which fruit do you wish to query? "; my $fruit = <STDIN>; my $fruits = $fruit_num{$fruit}; chomp $fruit; print "Number of" . $fruit . " is " . $fruits . "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash from prompt
by Athanasius (Archbishop) on Oct 13, 2014 at 04:01 UTC | |
by rshoe (Novice) on Oct 13, 2014 at 04:26 UTC | |
by Athanasius (Archbishop) on Oct 13, 2014 at 04:37 UTC | |
by rshoe (Novice) on Oct 13, 2014 at 04:35 UTC | |
by AnomalousMonk (Archbishop) on Oct 13, 2014 at 15:08 UTC |