I want to replace something with a path like C:\foo, so I:
s/hello/c:\foo
But that is invalid.
Do I need to escape some chars?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Two problems that I can see.
Your first problem is that your
s///replacement is not terminated:Your second problem, the one you asked about, is that the
\fis taken as a form feed escape sequence (ASCII 0x0C), just as it would be in double quotes, which is not what you want.You may either escape the backslash, or let variable interpolation “hide” the problem:
Take a look at the treatment of Quote and Quote-like Operators in
perlopfor more information.