in reply to Re: Re: Re: appending an array to a hash
in thread appending an array to a hash
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (dkubb) Re: (5) appending an array to a hash
by Anonymous Monk on Mar 23, 2001 at 01:19 UTC |