|go ahead... be a heretic|
Storing a Hash Made of Two Arrays in Another Hashby BJ_Covert_Action (Beadle)
|on Jan 10, 2012 at 17:40 UTC||Need Help??|
BJ_Covert_Action has asked for the wisdom of the Perl Monks concerning the following question:
So I've been bejiggering with this code for awhile and it's not working out the way I need it to. I am parsing a text file where the first line consists of headings that I would like to use for keys in a hash. The next few lines contain values. I'd like to store each line of values in a hash that is keyed by the headings in the first line, and contains the values in the second line. However, I'd like to store each of those hashes in a master hash that is keyed by the first value in each row. So the data I am looking at resembles the following:
I am trying to parse that code with the following subroutine (please note values are delimited by tabs, so the parsing is working as expected)
The line of code I am having trouble with is the one where I am trying to assign the values of %tmp_hash into the master hash %tickets. As you can see, I've tried a few different things which I've commented out. Basically, %tmp_hash is getting created just fine by assigning it the arrays @keys and @values. But I'd like to do something similar to make %tickets the hash of temporary hashes keyed by the first value in the @values array. I can't seem to get the context to work out.
Any help y'all could provide would be appreciated.