itisrich has asked for the wisdom of the Perl Monks concerning the following question:
Here is what I'm trying to do:
my $foo = "stuff"; open FD, "file.txt"; @data = <FD>; close FD; foreach (@data) { s/XXYY/$foo/; print; }
seems simple enough. I've done this before with no problems. For some reason, in this particular project, XXYY is not getting replaced by the contents of $foo, it is getting replaced by the actual variable name.
what was "XXYY" is now being printed as "$foo". Even though I have never had to do it before, I tried adding an "ee" at the end of the s///, but it made no difference.
Any help would be much appreciated.-rich
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: s/this/$that/ Gives Variable Name, Not Contents of Variable
by Corion (Patriarch) on Oct 07, 2013 at 15:27 UTC | |
|
Re: s/this/$that/ Gives Variable Name, Not Contents of Variable
by toolic (Bishop) on Oct 07, 2013 at 15:48 UTC | |
|
Re: s/this/$that/ Gives Variable Name, Not Contents of Variable
by VinsWorldcom (Prior) on Oct 07, 2013 at 15:31 UTC | |
|
Re: s/this/$that/ Gives Variable Name, Not Contents of Variable
by AnomalousMonk (Archbishop) on Oct 08, 2013 at 00:21 UTC | |
|
Re: s/this/$that/ Gives Variable Name, Not Contents of Variable
by AnomalousMonk (Archbishop) on Oct 07, 2013 at 22:13 UTC | |
|
Re: s/this/$that/ Gives Variable Name, Not Contents of Variable
by Marshall (Canon) on Oct 07, 2013 at 23:37 UTC | |
|
Re: s/this/$that/ Gives Variable Name, Not Contents of Variable
by Laurent_R (Canon) on Oct 07, 2013 at 17:16 UTC |