home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vile-src.zip / vile-8.1 / perl / manfilt.pl < prev    next >
Perl Script  |  1994-07-11  |  779b  |  32 lines

  1. #!/usr/local/bin/perl
  2. #
  3. # This script replaces backspace sequences with Ctrl-A attribute sequences
  4. # suitable for processing by vile.  It also attributes headings in bold.
  5. #
  6. # The C language version of this filter, also distributed with vile,
  7. # is much faster.
  8. #
  9. # $Header: /usr/build/vile/vile/perl/RCS/manfilt.pl,v 1.1 1994/07/11 22:56:20 tom Exp $
  10. #
  11. while (<>) {
  12.     if (/^[A-Z][A-Z]/) {
  13.     $_ = "\001" . length($_) . "B:" . $_;
  14.     next;
  15.     }
  16.     next unless /[\b]/o;
  17.     s/(.)([\b]\1)+/\002\1/go;
  18.     for (;;) {
  19.     last unless
  20.         $att =  /(_[\b]\002.)+/o && "UB:"
  21.          || /(_[\b].)+/o && "U:"
  22.              || /(\002.)+/o && "B:";
  23.     $beg = $`; $cur = $&; $end = $';
  24.     $cur =~ s/(_[\b])|\002//go;
  25.     $_ = $beg . "\001" . length($cur) . $att . $cur . $end;
  26.     }
  27. }
  28. continue {
  29.     print;
  30. }
  31.  
  32.