home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7468 < prev    next >
Encoding:
Internet Message Format  |  1992-12-16  |  1.4 KB

  1. Path: sparky!uunet!uswnvg!nv6.uswnvg.com!tcking
  2. From: tcking@uswnvg.com (Tim King)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: programming challenge
  5. Message-ID: <2999@uswnvg.uswnvg.com>
  6. Date: 16 Dec 92 23:12:13 GMT
  7. References: <1992Dec16.081836.1094@usage.csd.unsw.OZ.AU>
  8. Sender: news@uswnvg.uswnvg.com
  9. Organization: U S WEST NewVector Group, Inc.
  10. Lines: 32
  11. X-Newsreader: Tin 1.1 PL5
  12.  
  13. : gnb@baby.bby.com.au (Gregory N. Bond) writes:
  14. : | If you are editing man pages, they probably contain things like
  15. : | E^HE to make things bold, and _^HE (or E^H_, depending on your
  16. : | nroff) to underline them.  Rather than stripping the ^Hs then
  17. : | compressing the repeats, what about doing both at once:
  18. : | 
  19. : |     perl -pi.bak -e 's/(.)\cH$1/$1/g;s/_\cH(.)/$1/g;' {files}
  20. : | 
  21. : | (NB: \b is word boundry in regexps! Use ^H instead!)
  22.  
  23. Cameron Simpson (cameron@spectrum.cs.unsw.oz.au) wrote:
  24. : Ugh. Unless I'm missing something basic, this will work (and I've used this
  25. : script for years):
  26. :     exec sed 's/.^H//g' ${1+"$@"}
  27. : Thus,
  28. :     unbs man.out > man.text
  29. : It starts up much faster than Perl. That ^H is a literal control-H, guys.
  30.  
  31. Ugh, Ugh.  Unless ~I'm~ missing something basic, the 'col' utility is
  32. specifically for this purpose, stripping out ^H and repeated text.  Works
  33. for underlines too, gals.
  34.  
  35. col -bx < man.out > man.text
  36.  
  37. --
  38. Tim King, tcking@uswnvg.com or uunet!uswnvg!tcking
  39. US West NewVector Group Inc., Bellevue, Washington
  40. 206-450-8533
  41.