How do I escape a left paren in a Perl regex? How do I escape a left paren in a Perl regex? shell shell

How do I escape a left paren in a Perl regex?


You're forgetting that backslashes mean something to the shell, too. Try using single quotes instead of double quotes. (Or put your script in a file, where you won't need to worry about shell quoting.)


Gah. From command line, no less. Way too many levels of metacharacter interpretation.

Try replacing your double quotes with single quotes, see if that helps.


cjm's answer is probably the best. If you must do it at the command line, try using quotemeta() or the metaquoting escape sequence (\Q...\E). This worked for me in a bash prompt:

perl -pe "s/\Q\(\E/(/g" ./file