What is really going on here is that the output from man is designed to be printed on a paper printer. When the output includes something like x^Hx it's because man wants the printer to back up and overprint the x a second time, to render the x in boldface.

It's a big mistake to remove the ^H characters first and then to try to strip the doubled letters, because by removing the ^Hes, you've thrown away the information about which double letters should be stripped. What you want is to take the output from man and simply do this:

$text =~ s/.\cH//g;
That's all. nroff also uses _^Hx to indicate an underlined x character, and this will fix that also.

The other right solution was the one that mr.nick suggested: Use the col -b command to filter out the reverse motions before saving the output.


In reply to Re: Removing characters by Dominus
in thread Removing characters by TStanley

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.