volcan has asked for the wisdom of the Perl Monks concerning the following question:
ABC 123, 334, 442I'm mostly having trouble making a hash of a hash. I know that it can be done with a hash of arrays (which I also was having trouble with), but I want to do it with a hash of hashes, if possible. Here's my code:
FTE 442
HHR 443
NTR 554, 554
I had it where it was printing the same license plate numbers for all entries, but I changed the code and am not sure how I was even doing that. How do I properly make a hash of a hash from inputted files? How do I then output this in the form I showed above? I see how to get the keys out for the letter part of the license plates, but I'm stuck with how to show more than one set of numbers per letter group, or how to get each plate number to print out instead of one plate number printing out for each letter group. Thank you very much for any help given!#! usr/bin/perl while (<>) { $input = $_; #I strip the raw input of extraneous info to #get the letters and numbers which are each #made into variables #This part of the code is working well and is thus omitted $lets = $input; $nums= $input; $plates{$lets} = $nums{0}; } foreach $licPlate (keys %plates) { print "$licPlate "; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash of hashes
by GrandFather (Saint) on Mar 23, 2007 at 22:30 UTC | |
by volcan (Novice) on Mar 25, 2007 at 19:57 UTC | |
|
Re: hash of hashes
by Anno (Deacon) on Mar 23, 2007 at 21:28 UTC | |
by Joost (Canon) on Mar 23, 2007 at 21:46 UTC | |
by volcan (Novice) on Mar 23, 2007 at 22:08 UTC | |
by Anno (Deacon) on Mar 24, 2007 at 08:05 UTC | |
by volcan (Novice) on Mar 25, 2007 at 19:59 UTC |