use HTML::Template;
# open the html template
my $template = HTML::Template->new(filename => 'some/template.html');
# get the text ( get_file() code above)
my $sometext = get_file( '/some/textfile.txt' );
# fill in some parameters
$template->param( TEXT => $sometext );
# send the obligatory Content-Type
print "Content-Type: text/html\n\n";
# print the template
print $template->output;