Here's another alternative:
$sth->bind_col(1, \my $key); my %rows; while(my $row = $sth->fetchrow_hashref) { $rows{ $key } = $row; }
With this version you don't need to maintain a list of columns, and it will automatically make the first column the key in %rows. It's probably more efficient/faster to use $sth->fetchrow_hashref than doing a foreach since $row is made using a hash slice.
In reply to (dkubb) Re: (5) appending an array to a hash
by dkubb
in thread appending an array to a hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |