in reply to s/this/$that/ Gives Variable Name, Not Contents of Variable
I can't reproduce that:
my $foo = "stuff"; @data = <DATA>; foreach (@data) { s/XXYY/$foo/; print; } __DATA__ <XXYY> XXYY XXYY test
gives the following output:
>perl -w tmp.pl <stuff> stuff XXYY test
Maybe you are looking at the wrong output file?
In any case, you most likely want a /g at the end of your substitution, so that the second input line becomes stuff stuff on output.
|
|---|