in reply to Making hashes from arrays
Untested and broken (see Abigail-IIs post below), but I think your while loop could be replaced by
1 while @hall_details{$hall_id}{ qw[ hall_id hall_name upload_date uploaded_by photo_id ] } = $sth->fetchrow_array();
Update: I should never post untested code. It always bites me. Again, I think this would work.
my @fields; @( hall_details{$hall_id} }{ qw[ hall_id hall_name upload_date uploaded_by photo_id ] } = @fields while @fields = $sth->fetchrow_array();
which would save a lot of typing and to the offense of the "it don't matter how long it takes brigade", it might even be slightly more efficient:) Feel free to reformat that however suits your view of beauty.
That said, I have a sneaky suspicion that you can ask DBI to return the data as a hash to begin with, which would undoubtably be your best option.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Making hashes from arrays
by Abigail-II (Bishop) on May 22, 2003 at 23:21 UTC |