473,750 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hash of Hashes, Hash of Arrays and Hashes

eWish
971 Recognized Expert Contributor
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::Inde xed to keep the order.

Basically, $HOH{$key_of_HO A}->{$key_of_has h} = $element_from_H OA;

I have tried using nested for loops without success.

Any suggestions?

--Kevin
Jan 14 '09 #1
2 3552
numberwhun
3,509 Recognized Expert Moderator Specialist
@eWish
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!

Jeff
Jan 14 '09 #2
eWish
971 Recognized Expert Contributor
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];
  6.  
  7.         }
  8.  
  9. }
--Kevin
Jan 14 '09 #3

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

Similar topics

1
3911
by: andreas gammel | last post by:
I want to use Perl hash functionality (hashes of hashes, arrays of hashes, hashes of arrays) in my C programs. Other Perl functions (split, chomp, regular expressions) would be welcome too. Is there a C/C++ implementation of hashes/arrays ? Is there an Perl API/library for Visual C++ ? cheers
47
5087
by: VK | last post by:
Or why I just did myArray = "Computers" but myArray.length is showing 0. What a hey? There is a new trend to treat arrays and hashes as they were some variations of the same thing. But they are not at all. If you are doing *array", then you have to use only integer values for array index, as it was since ALGOL.
22
4640
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last month I had enough of extra proof that the cat doesn't hount mice anymore in more and more situations. And the surrent sicretisme among array and hash is the base for it. I summarized all points in this article:...
1
4753
by: bb | last post by:
I have a requirement to create and store in our database the users password in a couple of additional hashes (we currently store an MD5 hash) the spec is pretty brief... Spec: Store the NT Hash and Unix Crypt of password when a user creates/modifies password End.
14
2690
by: John Coleman | last post by:
Greetings, I am currently trying to learn Python through the excellent "Learning Python" book. I wrote my first non-trivial program, which began with several comment lines. One of the comment lines began with '#hash'. IDLE doesn't colorize it as a comment line but instead colors the word 'hash' in purple as if it were a key word. Wierd. The behavior seems easy to trigger: Just open up a new window in IDLE and enter these two lines: ...
3
12396
by: John Gregory | last post by:
I'm new to perl and have a question. The perl book says that hashes map keys to values. Using the reverse function you can map values to keys. My problem is I have a hash of arrays and I want to map an array of values to a particular key. Is there any way to do this? Thanks, John
24
4307
by: kdotsky | last post by:
Hello, I am using some very large dictionaries with keys that are long strings (urls). For a large dictionary these keys start to take up a significant amount of memory. I do not need access to these keys -- I only need to be able to retrieve the value associated with a certain key, so I do not want to have the keys stored in memory. Could I just hash() the url strings first and use the resulting integer as the key? I think what I'm...
11
2708
by: merrittr | last post by:
Hi in the code below in the main the hash table from K&R example replaces a node when a collision occurs What I am trying to do is set it up to "chain" another structure beside the node that it collides with can you spot what I am doing wrong? zork and 122 are to 2 that collide so the "zork" node gets overwritten by 121.
4
3440
by: MS | last post by:
Hi, I'm writing a PHP login script for a web site. I've looked at several examples on the web and some of them use MD5 hashes for the password. They do this in various ways. EG. a) Storing a MD5 hash of the original password in the database (in the password field), and then comparing the MD5 hash of the user entered
0
8838
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9396
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9342
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6808
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4888
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3323
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.