pleasehelp has asked for the wisdom of the Perl Monks concerning the following question:
Hi all! Can someone tell me why this doesn't work?
#!/usr/bin/perl use warnings; use strict; my %numbers=( nameA => "1234567", nameB => "2234567", nameC => "3234567", nameD => "4234567", nameE => "5234567" ); print "Who's number are you looking for? : \n"; my $who = <STDIN>; print "$who number is $numbers{$who}\n";
this is the output i get:
C:\BegPerl\chap3\Exercises>chap3_ex3.pl Who's number are you looking for? : "nameA" Use of uninitialized value in concatenation (.) or string at C:\BegPerl\chap3\Exercises\chap3_ex3.pl line 21, <STDIN> li ne 1. nameA number is
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: user defined variable as hash key index
by FunkyMonk (Bishop) on Oct 15, 2007 at 21:27 UTC | |
by pleasehelp (Initiate) on Oct 15, 2007 at 21:54 UTC | |
|
Re: user defined variable as hash key index
by naikonta (Curate) on Oct 16, 2007 at 01:12 UTC |