use HTML::Template my %vars = getStuffFromDB(); # open the html template my $t = HTML::Template->new(filename => 'ffff.tmpl'); $t->param( foo => $var{'foo'}; # open $filehandle to .html file .. snip .. # output print $fh $t->output;