use strict; use warnings; use HTML::Template; use DBI; my $id = shift || 42; my $dbh = DBI->connect( ... ); my $tmpl = HTML::Template->new(filehandle => \*DATA); my $product = $dbh->selectall_arrayref(q{ SELECT image, price, description, serial FROM product WHERE id = ? }, {Slice => {}}, $id); # i think it's better to use a variable instead of # passing the results from the query directly to the # $tmpl->param method (easier debugging) $tmpl->param(product => $product); print $tmpl->output; __DATA__ image: price: description: serial: