I'm not sure what exactly to call it, but I was able to reproduce my problem with two single line.
Starting with the test.txt file containing the following:
foo
After executing the following command (in bash):
perl -n -e "s/(\w)oo/$1ar/; print;" test.txt
output is equal to ' far'
However, when I enter a variable containing the replacement string,
perl -n -e '$bar = q($1ar); s/(\w)oo/$bar/; print;' test.txt
the output is equal to. ' $1ar'
What do I need to change so that the second program also displays ' far' and what keywords do I need to know so that this answer is answerable?
Also, I tried changing the second to s /// e, with no effect.
Edit: This was not the question I wanted to ask here .
source
share