my $allshows; for my $i ( 0 .. $#ids ) { $stmt = "SELECT id,title,teaser,number FROM shows WHERE id = '$ids[$i]'; &execute_it( $stmt ); #db operations to grab all matches push @$allshows, $sth->fetchall_arrayref({}); } $template = HTML::Template->new(filename => 'showslisting.tmpl'); $template -> param( showlist => $allshows ); #### $VAR1 = [ { 'id' => '6', 'teaser' => 'Domestic violence has been called a serious health crisis.', 'title' => 'Battered and Broken', 'number' => '214' } ];