Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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 (Chancellor) 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 (Canon) 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
[LanX]: hm just read an article on claiming that RPerl is 250 times faster. ... it's that even possible?
[marto]: under certain circumstances perhaps
[RonW]: as I understand it, RPerl "compiles" a subset of Perl to C, so I would expect the final executable to run a lot faster

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2017-05-22 20:13 GMT
Find Nodes?
    Voting Booth?