#!/usr/bin/perl -w use strict; my $template = get_file ( 'c:/some/template.htm' ); my $textfile = get_file ( 'c:/some/textfile.txt' ); $template =~ s//$textfile/ or die "No token!"; print "Content-Type: text/html\n\n"; print $template; sub get_file { my $file = shift; open FILE, $file or die "Can't open $file $!\n"; local $/; my $content = ; return $content; } #### 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;