#!/usr/bin/perl -w print "Content-type: text/html\n\n"; use HTML::Template; use strict; my @datalist; my $template = HTML::Template -> new(filename => "../htmlfilename.tmpl"); while (my @ary = $sth->fetchrow_array()) { my %one_record = ( dataid => $ary[0], datalisting => $ary[1], ); push (@datalist, \%one_record); } $template->param(datalist => \@datalist); print $template->output();