develooper Front page | perl.beginners | Postings from October 2009

Building a record on the fly via hash of hashes

Thread Next
From:
Soham Das
Date:
October 8, 2009 22:14
Subject:
Building a record on the fly via hash of hashes
Message ID:
555672.78064.qm@web95311.mail.in2.yahoo.com
Hello All,

I am doing some file reading operation, and parsing the data(its a CSV file) with a hash reference and then intend to store it in a record.

something like:

loop: until file ends;
                 $hashref->{'A'}=$filehandle->{'Action'};
                 $hashref->{'B'}= $filehandle->{'Name'};
                 $hashref->{'C'}= $filehandle->{'System'};
                 $hashref->{'D'}=($filehandle->{'Price'});

                 $recordref->{$hashref->{'B'}}= $hashref;

loop : ends

Here Action, Name,System,price are the CSV headers. 

Now, when the first line is read, the details are parsed and stored in the $recordref as a hash reference. Now when the loop iterates, and goes to the second line. The first line contents are lost. Because the hash reference now points to the newer data.

How do I overcome this?
More importantly do we have a push equivalent for hash of hashes?

Soham


Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About