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;