Another way to completely defeat scalar or array interpolation in regexes (as in strings) is by use of ' (single-quote) delimiters for the s/// substitution:
(This applies also to m// and qr// operators.) See perlop.c:\@Work\Perl\monks\marek1703>perl -wMstrict -le "my $s = '-#-$-%-&-~-_-}-{-^-0-$%&~_}{^0'; print qq{'$s'}; ;; $s =~ s' (?= [#$%&~_{}^]) '\\'xmsg; print qq{'$s'}; " '-#-$-%-&-~-_-}-{-^-0-$%&~_}{^0' '-\#-\$-\%-\&-\~-\_-\}-\{-\^-0-\$\%\&\~\_\}\{\^0'
In reply to Re^5: Escape special characters for a LaTeX file
by AnomalousMonk
in thread Escape special characters for a LaTeX file
by marek1703
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |