mohanm_eee has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I have a text file as below and saved it as "file.txt"
"create variable $VAR alarm_object 0"Iam trying to read this in a perl script and printing it by substituting the "$VAR" variable
$VAR = TEMP_VAR open (FILE,"<", "file.txt") or die $!; while (<FILE>) { chomp; eval(print "$_\n"); } close (FILE);
I want the output as
"create variable TEMP_VAR alarm_object 0"I tried to achieve this using eval function. It is not working as expected.
How can i achieve this in perl?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Substituting Variables while reading text file
by toolic (Bishop) on Aug 05, 2014 at 18:04 UTC | |
Re: Substituting Variables while reading text file
by frozenwithjoy (Priest) on Aug 05, 2014 at 18:05 UTC | |
Re: Substituting Variables while reading text file
by Laurent_R (Canon) on Aug 05, 2014 at 18:52 UTC | |
Re: Substituting Variables while reading text file
by aitap (Curate) on Aug 07, 2014 at 07:21 UTC |
Back to
Seekers of Perl Wisdom