
aiikahn
Novice
Feb 22, 2008, 10:40 PM
Post #1 of 4
(235 views)
|
|
Help with hashes
|
Can't Post
|
|
I'm fairly new with Perl and I was wondering if anyone could tell me why my code isn't working below. I'm trying to print the value when the key is entered via user input. Here's the code below: %hash = (1,'Fred' , 2, 'Flintstone', 3, 'Barney', 4, 'Rubble'); print "Number: "; $number = <STDIN>; print $hash{$number}; When I run the program, it only gives me a blank line. I'd greatly appreciate any help. Thank you. -AR
|