my $response = HTML::Template->new( filename => $filename, path => "/$config{'template_dir'}/$theme/", die_on_bad_params => 0, global_vars => 1, associate => $request_cgi, loop_context_vars => 1, filter => {sub=> \&compress,format=> 'scalar'}, ); my $sqlquery = 'select t.field_one as DATA1, t.field_two as DATA2 from table_one t order by t.field_one ASC'; my $sth = exec_query($sqlquery) or die("Wacka!!"); my $arrayref = $sth->fetchall_arrayref({}); $response->param(LOOPTEST => $arrayref);