more useful options | |
PerlMonks |
Re: assign an array into hashby johngg (Canon) |
on Apr 26, 2007 at 09:37 UTC ( [id://612171]=note: print w/replies, xml ) | Need Help?? |
There are a few problems with your code. Firstly, it is always recommended to place use strict; and use warnings; at the top of your scripts to help avoid typos etc. When you read your file you construct an array with one element per line where you actually need two. Interpolating an array into a string is only going to result in a single string being assigned to your hash. In any case, qw( ... ) doesn't interpolate so you were assigning the string "@con" to your hash. You can assign an array to a hash but you will get a warning if there aren't an even number of elements..
Here's the output
I hope this helps you. Cheers, JohnGG
In Section
Seekers of Perl Wisdom
|
|