in reply to building a hash from a database
How big of a CSV are we looking at here? If you have the memory, you could simplify with $sth->fetchall_arrarref({}) which would give you something like this:
Then with your friend map, you can massage this structure thusly:$VAR1 = [ { 'id' => 1, 'fname' => 'John', 'lname' => 'Smith', }, { 'id' => 2, 'fname' => 'Sally', 'lname' => 'Smith', }, ];
which would result in something along the lines ofmy %hash = map { $_->{'id'} => $_ } @$data;
$VAR2 = { '1' => { 'id' => 1, 'fname' => 'John', 'lname' => 'Smith', }, '2' => { 'id' => 2, 'fname' => 'Sally', 'lname' => 'Smith', }, };
Ivan Heffner
Sr. Software Engineer, DAS Lead
WhitePages.com, Inc.
Sr. Software Engineer, DAS Lead
WhitePages.com, Inc.
|
---|
In Section
Seekers of Perl Wisdom