I am calling a perl one-liner inside a Perl script.
The intention of the one-liner is to remove the trailing space from a file.
Inside the main perl script:
`perl -pi -e 's/\s+$//' tape.txt`;
Now it is throwing me an error Substitution replacement not terminated at -e line 2.
Where is it going wrong?
It's because of the $/
(special variable) inside your main perl script. Note that variables are interpolated inside ``
strings just like inside ""
strings, and the fact that there are some single quotes in there doesn't change that. You need to escape that $
:
`perl -pi -e 's/\s+\$//' tape.txt;`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With