blueblue has asked for the wisdom of the Perl Monks concerning the following question:
Hi, So what I am trying to do is print the values from a hash based on user input. So the user input needs to match the key in order to print the associated value. so I was thinking it would go something like this:
I looking for others ways to approach this, any input would be a lot of help thanks!use strict; use warnings; my %words = ('hello' => 'world'); print 'type a word: ' chomp(my $inData = <>); if($inData eq (keys %words){ print 'value: ', values %words; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting values from a Hash from user input
by GrandFather (Saint) on Nov 21, 2013 at 20:31 UTC | |
|
Re: Getting values from a Hash from user input
by Kenosis (Priest) on Nov 21, 2013 at 21:10 UTC | |
by Eily (Monsignor) on Nov 21, 2013 at 21:33 UTC | |
by Kenosis (Priest) on Nov 21, 2013 at 21:36 UTC | |
by blueblue (Initiate) on Nov 21, 2013 at 22:01 UTC | |
|
Re: Getting values from a Hash from user input
by blueblue (Initiate) on Nov 22, 2013 at 14:46 UTC |