I have a simple line of Perl
s/$var/'string'/g
The issue is that $var contains a string like jkdlsf$lkjl
. Note the dollar sign in the middle. It seems because of this dollar sign the replace is not working. How do I escape this when it is inside a variable?
Use the \Q
quote:
s/\Q$var/'string'/g
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