in reply to Selecting a specific hash key to find a value
#!/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";
%Number = (1 => 'Red', 2 => 'Yellow', 3 => 'Green');
@Number = ('Red', 'Yellow', 'Green'); print $Number[$a]."\n";
|
|---|