|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Re: novice with hash/data file questionby chromatic (Archbishop) |
| on Sep 02, 2008 at 08:25 UTC ( [id://708416]=note: print w/replies, xml ) | Need Help?? |
|
foreach $i ($data[0], $data[1]){
What do you expect this to do? There's no @data in your program; what does it contain? '$short' => '$place',The key of this pair is the literal string $short and not the contents of the variable $short. Likewise the value of this pair is the literal string $place and not the contents of the variable $place. When you use a scalar variable in a double-quoted string, Perl interpolates the value of that variable in the string (that is, Perl looks up the value and inserts it into the string). There's no interpolation in single-quoted strings. %stuff = ( ... )This will overwrite the hash at each iteration of the loop. Similarly, closing your (unused) filehandle within the body of the loop will close it multiple times. I suspect you want a program more like:
... but that's a rough guess. (Because you're a novice, let me point out gently that naming a filehandle OUT when you open it for reading will confuse people.)
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||||||