http://qs321.pair.com?node_id=1096337


in reply to Substituting Variables while reading text file

The problem is probably that you are using a bare word instead of a string. Try changing:
$VAR = TEMP_VAR
to
my $VAR = "TEMP_VAR";
and it should work. My quick test with a Perl one-liner under Unix:
$ echo 'create variable $VAR alarm_object 0' | perl -e '$VAR = "TEMP_V +AR"; while (<>) { chomp; eval (qq{print "$_\n";});}' create variable TEMP_VAR alarm_object 0
My understanding is that this is closer to what the OP wanted than s///, but I may of course be wrong.