home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7451 < prev    next >
Encoding:
Text File  |  1992-12-16  |  1.5 KB  |  44 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!munnari.oz.au!metro!usage!spectrum!cameron
  3. From: cameron@spectrum.cs.unsw.oz.au (Cameron Simpson)
  4. Subject: Re: programming challenge
  5. Message-ID: <1992Dec16.081836.1094@usage.csd.unsw.OZ.AU>
  6. Sender: news@usage.csd.unsw.OZ.AU
  7. Nntp-Posting-Host: fuligin.spectrum.cs.unsw.oz.au
  8. Reply-To: cameron@spectrum.cs.unsw.oz.au (Cameron Simpson)
  9. Organization: CS&E Computing Facility, Uni Of NSW, Oz
  10. References: <1992Dec12.100131.11703@zooid.guild.org> <1992Dec16.043128.7616@bby.com.au>
  11. Date: Wed, 16 Dec 1992 08:18:36 GMT
  12. Lines: 30
  13.  
  14. gnb@baby.bby.com.au (Gregory N. Bond) writes:
  15. | If you are editing man pages, they probably contain things like
  16. | E^HE to make things bold, and _^HE (or E^H_, depending on your
  17. | nroff) to underline them.  Rather than stripping the ^Hs then
  18. | compressing the repeats, what about doing both at once:
  19. |     perl -pi.bak -e 's/(.)\cH$1/$1/g;s/_\cH(.)/$1/g;' {files}
  20. | (NB: \b is word boundry in regexps! Use ^H instead!)
  21.  
  22. Ugh. Unless I'm missing something basic, this will work (and I've used this
  23. script for years):
  24.  
  25.     #!/bin/sh
  26.     #
  27.     # Remove nroff-style underlining and overstriking.
  28.     # Works for other stuff, too.
  29.     #
  30.  
  31.     exec sed 's/.^H//g' ${1+"$@"}
  32.  
  33. Thus,
  34.     unbs man.out > man.text
  35.  
  36. It starts up much faster than Perl. That ^H is a literal control-H, guys.
  37.     - Cameron Simpson
  38.       cameron@cs.unsw.oz.au, DoD 0743
  39. --
  40. "The engine purrs beneath me with a purpose,
  41.  ready for the pleasure of my hand upon the throttle." - Peter Smith
  42.