Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Substituting Variables while reading text file

by Laurent_R (Canon)
on Aug 05, 2014 at 18:52 UTC ( [id://1096337]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1096337]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-06-25 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.