good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Table manipulation, array or hash?by ack (Deacon) |
on Mar 23, 2010 at 17:36 UTC ( [id://830348]=note: print w/replies, xml ) | Need Help?? |
I took a somewhat similar approach to the other reponders and used a Hash of Hashes (HoH) and combined the two data values for each entry into a string which could latter be split() so as to avoid the third level of deep data structure. My approach (with just the principle code snippet) is shown below:
I have also put the OP's example data input into an array, @lines, to simplify my testing. Assuming that the lines are being read in from a file, one would do a foreach (<INPUT>){} rather than my foreach (@lines){} structure. I hope this helps and shows yet another approach that works. I didn't spend a lot of time optimizing or simplifying. I figure that is a worthwhile exercise for the reader and the OP.
ack
Albuquerque, NM
In Section
Seekers of Perl Wisdom
|
|