Just to generalize the script I gave you... This replaces any variable in the template with its value in the program.
It's a quick-and-dirty fix that may solve your problem if you're in a rush. Of course, as others have noted, it would be better if you used a proper templating system. Note also that this only works for simple scalar variables (e.g.
$thing,
$ZOWIE), not for more complicated variables such as array or hash elements (e.g.,
$var[$num] or
$var{thing}).
my $template = snarf('template.htm');
while ($template =~ /(\$[:alpha:]\w*)/g) {
my $variable_name = $1;
my $value = eval $variable_name;
$template =~ s/\Q$variable_name\E/$value/g;
}
print $template;