home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / perl / digest.pl < prev    next >
Perl Script  |  1994-03-07  |  3KB  |  103 lines

  1. #! /usr/bin/perl
  2. # Modified: 18 October 1992
  3. #
  4. #    This is 'digest' a program to run elm on a digest as a folder.
  5. #    Copyright (C) 1990-1991  David J. Camp
  6. #
  7. #    This program is free software; you can redistribute it and/or modify
  8. #    it under the terms of the GNU General Public License as published by
  9. #    the Free Software Foundation; either version 1, or (at your option)
  10. #    any later version.
  11. #
  12. #    This program is distributed in the hope that it will be useful,
  13. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. #    GNU General Public License for more details.
  16. #
  17. #    You should have received a copy of the GNU General Public License
  18. #    along with this program; if not, write to the Free Software
  19. #    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. #
  21. # david@campfire.stl.mo.us           ^     David J. Camp                #
  22. # wupost.wustl.edu!campfire!david  < * >   +1 314 382 0584              #
  23. #                                    v     "God loves material things." #
  24. #         I am a member of the League for Programming Freedom.          #
  25. #
  26. # from the elm menu, type |digest<return>
  27. #
  28. $first = 1;
  29. if (-t STDIN)
  30.     {
  31.     print STDERR "Usage: \"|digest\" from elm menu\n";
  32.     exit 3;
  33.     }
  34. $| = 1;
  35. open (FOLDER, ">/tmp/dig$$");
  36. $first = 1;
  37. while (<>)
  38.     {
  39. #    print $_;
  40.     if ($first)
  41.         {
  42.         if (! m/^From /)
  43.             {
  44.         print FOLDER "From dummy Wed Feb  29 12:12:12 1990\n";
  45.             }
  46.         $first = 0;
  47.         }
  48.     $match = 0;
  49.     if (/^[0-9]*\)$/)
  50.     { $match = 1; }
  51.     if (/^\([0-9]*\) ----\n$/)
  52.     { $match = 1; }
  53.     if (/^*\n$/)
  54.     { $match = 1; }
  55.     if (/^------\n$/)
  56.     { $match = 1; }
  57.     if (/^-----------------------------\n$/)
  58.     { $match = 1; }
  59.     if (/^------------------------------\n$/)
  60.     { $match = 1; }
  61.     if (/^-------------------------------------------------------\n$/)
  62.     { $match = 1; }
  63.     if (/^============================================================\n$/)
  64.         { $match = 1; }
  65.     if
  66. (/^----------------------------------------------------------------------*\n$/)
  67.     { $match = 1; }
  68.     if
  69. (/^------------------------------------------------------------------------=\n$/)
  70.     { $match = 1; }
  71.     if 
  72. (/^=========================================================================$/)
  73.     { $match = 1; }
  74.     if 
  75. (/^========================================================================/)
  76.     { $match = 1; }
  77. if ($match || $first)
  78.         {
  79.     $break = $_;
  80.     $_ = "";
  81.     for ($ctr = 0; ! (eof() || /[\041-\177]/); $ctr++)
  82.             {
  83.             $_ = <>;
  84.             }
  85.     if (/^[^ \t\r\n:]+: /)
  86.         {
  87.         print FOLDER "From dummy Wed Feb  29 12:12:12 1990\n";
  88.         }
  89.     else
  90.         {
  91.         print FOLDER $break;
  92.         for ($ctr--; $ctr > 0; $ctr--)
  93.         {
  94.         print FOLDER "\n";
  95.         }
  96.         }
  97.         }
  98.     print FOLDER $_;
  99.     $first = 0;
  100.     }
  101. close (FOLDER);
  102. exec ("elm -f /tmp/dig$$ <&2 ; /bin/rm -f /tmp/dig$$");
  103.