Most literally, you can't. Try an array of hash refs:
On the other hand, if you have an id column ( eg. primary key ), you could easily make it ( or any other column, for that matter ) a key in a Hash of Hashes:my $sth = $dbh->prepare(<<__SQL__); SELECT * FROM $table; __SQL__ $sth->execute; my $table_data = []; push @{$table_data}, $_ while $sth->fetchrow_hashref; $sth->finish;
Enjoy!my $sth = $dbh->prepare(<<__SQL__); SELECT * FROM $table; __SQL__ $sth->execute; my $table_data = {}; $table_data->{$_->{id}} = $_ while $sth->fetchrow_hashref; $sth->finish;
--
Casey
I am a Superhero.
In reply to Re: How can I read records from a table in a database and represent it in a hash?
by cwest
in thread How can I read records from a table in a database and represent it in a hash?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |