By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,811 Members | 1,978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,811 IT Pros & Developers. It's quick & easy.

Hash of Hashes, Hash of Arrays and Hashes

Expert 100+
P: 971
I am in need of a good tutorial that explains taking the keys of one hash and the elements in a HOA and making them a HOH. I have a file that has is pipe delimited with 374 fields per line and 7.500 plus lines per file. I have about five of these files. I need to get this into a database and did not want to do it manually, Preserving the order is crucial. I am using Tie::Hash::Indexed to keep the order.

Basically, $HOH{$key_of_HOA}->{$key_of_hash} = $element_from_HOA;

I have tried using nested for loops without success.

Any suggestions?

Jan 14 '09 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 3,503
Don't know if you have seen this one yet, but here is one of my go-to pages for hash of <anything>.

Hope it helps!

Jan 14 '09 #2

Expert 100+
P: 971
Here is what I ended up doing.

Expand|Select|Wrap|Line Numbers
  1. foreach my $id (keys %listings) {
  2.      my $count = 0;
  3.         foreach my $field (keys %fields) {
  4.             $count++;
  5.             $data_hash{$id}->{$field} = $listings{$id}[$count-1];
  7.         }
  9. }
Jan 14 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.