BAH! You don't really want to do it this way at all. You should look into the Embperl modules, specifically HTML::Embperl It does exactly what you want to do. You have an HTML template file, but you actually embed Perl code in this file. HTML::Embperl then takes this file, and evaluates whatever Perl code is in the file, and generates an HTML file from this. The general format of this is to have a bunch of html, then with square brackets you embed Perl code that gets executed and the whatever value that block returns is inserted into the document. Just do a search for Embperl on www.perl.com and you will find it. It comes with good documentation so you should be able to figure out the specifics without too much heart burn.
Hope this helps,
Andrew Gibbs