Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

special character substitution

by bill b (Initiate)
on Jun 10, 2013 at 19:41 UTC ( #1038142=perlquestion: print w/replies, xml ) Need Help??
bill b has asked for the wisdom of the Perl Monks concerning the following question:


I'm polishing man page output from pandoc (google it). I need to clean up cruft that occurs around the man page bullet macros and replace it with \(bu (bullet macro syntax). Here's what I have:


The matching works perfectly, but no matter how much I play with the substitution string, I always get (bu without the initial backslash. I've tried /\\(bu/, /\\\(bu/, /Q and /E, but nothing works. I always get (bu in the output.

TIA, Bill

Replies are listed 'Best First'.
Re: special character substitution
by choroba (Bishop) on Jun 10, 2013 at 19:57 UTC
    Works for me:
    $_ = "T}\@T...T}\@T{"; s/T\}\@T.*T\}\@T\{/\\(bu/sm; print;


    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Thanks. I'm an idiot--I was inadvertently erasing the \ in another part of postprocessing. Sigh. thanks again, bill
Re: special character substitution
by AnomalousMonk (Chancellor) on Jun 10, 2013 at 22:08 UTC

    Also, using  ' (single-quote) as a delimiter for either or both of the substitution pattern or replacement string of a  s/// will force the use of single-quotish (non-)interpolation and escapology.

    >perl -wMstrict -le "$_ = 'T}@T...T}@T{'; s'T}@T.*T}@T{'\(bu'sm; print qq{'$_'}; " '\(bu'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1038142]
Approved by hdb
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2018-05-24 20:19 GMT
Find Nodes?
    Voting Booth?