in reply to Selecting a specific hash key to find a value

Your have to chomp the variable, that is remove the trailing \n :

#!/usr/bin/perl print "Give me a number for the tile and I will tell you the color\n"; chomp($a=<STDIN>); print $a."\n"; %Number = qw(1 Red 2 Yellow 3 Green 4 Black 5 Purple 6 Pink 7 Brown 8 Blue 9 Orange); print $Number{$a}."\n";

BTW, your code will be cleaner if you construct your hash like this :

%Number = (1 => 'Red', 2 => 'Yellow', 3 => 'Green');

It'll be clearer that you are using a hash table.

On the other way you could use a array for that :

@Number = ('Red', 'Yellow', 'Green'); print $Number[$a]."\n";

That is much more logical, as your keys are consecutive numbers. Hash a usually used when keys are strings or more complicated objects.

--
zejames