Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: substituting 1 escaped character for another

by pryrt (Abbot)
on Jul 26, 2018 at 16:59 UTC ( [id://1219327]=note: print w/replies, xml ) Need Help??


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 (Cardinal) 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.
    s/\(/</

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

    s/\(/</g

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

    tr/(/</

    ($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,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1219327]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-19 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found