package Tie::STHRows; use base Tie::Array; sub TIEARRAY { my $class = shift; my $sth = shift; die "You must pass a statement handler!" unless ref($sth) eq "DBI::st"; my %row; $sth->bind_columns( \( @row{ @{$sth->{NAME_lc} } } )); bless ([$sth,\%row],$class); } sub FETCH { my $self = shift; $self->[0]->fetch; return +{ %{$self->[1]} }; # per tye's suggestion } sub FETCHSIZE { ${+shift}[0]->rows; }; sub DESTROY { ${+shift}[0]->finish; } 1; __DATA__ sample snippet for how it works: $sth = $dbh->prepare(...); $sth->execute; tie @loopdata, Tie::STHRows, $sth; $template->param(LOOPDATA => \@loopdata); and your template: ...