in reply to substituting 1 escaped character for another

that works for me. could you show us how it doesn't work for you (SSCCE):

__LINUX__ sh-3.00$ perl -le 'print $x = "healthy(b"; $x =~ s/\(/\</; print $x' healthy(b healthy<b sh-3.00$ perl -v This is perl, v5.8.5 built for i386-linux-thread-multi ... __WINDOWS__ C:\>perl -le "print $x = 'healthy(b'; $x =~ s/\(/\</; print $x" healthy(b healthy<b C:\>perl -v This is perl 5, version 26, subversion 2 (v5.26.2) built for MSWin32-x +64-multi-thread ...

Replies are listed 'Best First'.
Re^2: substituting 1 escaped character for another
by choroba (Archbishop) on Jul 26, 2018 at 17:49 UTC
    Also note that the backslash in the replacement part is useless and could be even misleading as someone might think that \< has a special meaning.

    If there are more parentheses to replace, use the /g modifier:


    Also, in case of single character replacements, you can use transliteration:


    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,