in reply to Using hashes instead of arrays with database results

:)

Yes, i mentioned that i tend to avoid using hashes to store database result sets, but that doesn't mean that i avoid hashes in database code. One of my favorite tricks is to store the names of columns in an array and a hash:

my $sth = $dbh->prepare('select stdout,stdin from stderr'); $sth->execute; my @field = @{$sth->{'NAME'}}; my %field = map { $field[$_] => $_ } (0..$#field); my $rows = $sth->fetchall_arrayref();

Now i know what belongs where, but have other issues with your code, namely printing inside a sub like that i meant - storing the 'print' results in a string and returning that. How about transforming the data structure into another one and then having one printing subroutine? The obvious drawback is memory consuption, of course.

My other problem is sorting outside the database. I am sure there is at least one situation 'out there' that calls for it, but most of the time you should let the database do it.

But, good stuff none-the-less. I am not going to refute it. I'll leave that for princepawn, whom you didn't see coming. ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)