my @ar = (); while (my $hr = $sth->fetchrow_hashref() ) { push @ar, $hr; } $s->ar = \@ar; $s->rows = @ar; #### $s->ar = $sth->fetchall_arrayref({}); $s->rows = @{$s->ar}; #### # Assume $sth is a valid statement handle my $params = $sth->fetchall_arrayref({}); my $template = new HTML::Template (filename => 'file.name'); $template->param(TABLENAME => $params); print $template->output(); ####