in reply to Reading escape characters from file

Perhaps consider approaching the question from another angle and simply have two template vars.

This uses HTML::Template to demonstrate a possible way to do it.

#!/usr/local/bin/perl use strict; use warnings; use HTML::Template; my $tmpl = do{local $/;<DATA>}; my $t = HTML::Template->new(scalarref => \$tmpl); $t->param( vehicle_uc => q{BUS}, vehicle_lc => q{bus}, ); print $t->output; __DATA__ sam is riding an uppercase <TMPL_VAR vehicle_uc> sam is riding an lowercase <TMPL_VAR vehicle_lc>
sam is riding an uppercase BUS sam is riding an lowercase bus