in reply to The fetchall_answer!
in thread By ref or by ..well..ref!

This is the kind of problem which Data::Dumper is very helpful for. If you run it on the database output you will find that you are getting back array references rather than hash references.

This is the thing I most dislike about DBI's API. There are a ton of efficient ways to use positional logic, but if you want to use name-based logic, you are definitely a second-class citizen. However name-based logic is much better from a development perspective if performance is not utterly critical.

But anyways you can just use a bit of code like this:

# Takes a statement handle, and returns the entire result # set as a reference to an array of hashes. sub fetchall_arrayref_hash { my $sth = shift; my @rows; while (defined(my $row = $sth->fetchrow_hashref())) { push @rows, $row; } return \@rows; } # Then elsewhere $template->param(table1 => fetchall_arrayref_hash($sth));
The fact that someone doesn't provide the interface that you want is no reason not to provide it yourself...