While I know you can do this with perl, I would also say to not reinvent the wheel -- look at CPAN modules like Template Toolkit which easily support variable substituion into a predefined file, e.g.:
.pl file
use Template;
%hash = ( name => 'my name' );
$tt = new Template;
$tt->process( 'template.html', { data = \%hash } );