use DBI;
use CGI;
use HTML::Template;
my $cgi = CGI->new;
my $dbh = DBI->connect('dbi:mysql:xxxx:localhost', 'xxxx', 'xxxx');
my $t = HTML::Template->new(filename => 'db.tmpl');
$t->param(ROWS => $dbh->selectall_hashref('select id, name, price from products'));
$dbh->disconnect;
print $cgi->header;
print $t->output;