home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / HOWTO / OTHER-FO / PRINTING.TAR / info2text.pl next >
Encoding:
Text File  |  1994-02-20  |  1.0 KB  |  52 lines

  1. # Perl script to convert info files into text file
  2.  
  3. while(<STDIN>) {
  4.   if (/^$/) {
  5.     $inmenu=0;
  6.     # Skip lines
  7.     $_=<STDIN>;
  8.     unless(/Node: Top/) {
  9.       $_=<STDIN>;
  10.       $title=<STDIN>;
  11.       $_=<STDIN>;
  12.       if ($title =~ / Index$/) {$inmenu=1;}
  13.       else {
  14.     if (/^\*+$/) {
  15.       $chapter++; $section=0; $subsection=0;
  16.       print "$chapter $title";
  17.       unless ($toc) {
  18.         print substr("******",0,length("$chapter "));
  19.         print;
  20.       }
  21.     }
  22.     if (/^\=+$/) {
  23.       $section++; $subsection=0;
  24.       print "$chapter.$section $title";
  25.       unless ($toc) {
  26.         print substr("=========",0,length("$chapter.$section "));
  27.         print;
  28.       }
  29.     }
  30.     if (/^\-+$/) {
  31.       $subsection++;
  32.       print "$chapter.$section.$subsection $title";
  33.       unless ($toc) {
  34.         print substr("-------------",0,length("$chapter.$section.$subsection "));
  35.         print;
  36.       }
  37.     }
  38.       }
  39.     }
  40.   }
  41.   else {
  42.     if (/^\* Menu:$/) {$inmenu=1;}
  43.     s/\*Note/See Also:/g;
  44.     s/:://g;
  45.     if ((!$toc && $title) || ($toc && !$title)) {
  46.       print unless($inmenu);
  47.     }
  48.   }
  49. }
  50.  
  51.  
  52.