Xref: feenix.metronet.com comp.mail.elm:3065
Newsgroups: comp.mail.elm
Path: feenix.metronet.com!news.utdallas.edu!wupost!wubios.wustl.edu!david
From: david@wubios.wustl.edu (David J. Camp)
Subject: Oops, Here Comes "digest" Again
Message-ID: <1993Sep14.194514.16693@wubios.wustl.edu>
Sender: david@wubios.wustl.edu (David J. Camp)
Organization: Division of Biostatistics, WUMS, St. Louis, MO
Date: Tue, 14 Sep 1993 19:45:14 GMT
Lines: 107

I recently posted my "digest" program, a dedigestifier especially for
use with elm.  Unfortunately, it was mangled by UseNet during
transmission due to non-ascii characters in the file.  I have remedied
the situation, and am reposting digest below.  -David-

#! /usr/bin/perl
# Modified: 14 September 1993
#
#    This is 'digest' a program to run elm on a digest as a folder.
#    Copyright (C) 1990-1993  David J. Camp
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 1, or (at your option)
#    any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# david@campfire.stl.mo.us             David J. Camp         ^      #
# wupost.wustl.edu!campfire!david      +1 314 382 0584     < * >    #
# I am a member of:  The League for Programming Freedom.     v      #
# Ask: lpf@uunet.uu.net                "God loves material things." #
#
# from the elm menu, type |digest<return>
#
if (-t STDIN)
    {
    print STDERR "Usage: \"|digest\" from elm menu\n";
    exit 3;
    }
$| = 1;
open (FOLDER, ">/tmp/dig$$");
$hang = 0;
$first = 1;
while (! eof (STDIN))
    {
    if (! $hang)
	{
	$_ = <>;
	}
    $hang = 0;
    if ($first)
        {
        if (! m/^From /)
            {
	    print FOLDER "From dummy Wed Feb  29 12:12:12 1990\n";
            }
        $first = 0;
        }
    $match = 0;
    if (/^-[^ ]/)
	{ $match = 1; }
    if (/^[0-9]*\)$/)
	{ $match = 1; }
    if (/^\([0-9]*\) ----\n$/)
	{ $match = 1; }
    if (/^\001\001*\n$/)
	{ $match = 1; }
    if (/^============================================================\n$/)
        { $match = 1; }
    if 
(/^=========================================================================\n$/)
	{ $match = 1; }
    if 
(/^========================================================================/)
	{ $match = 1; }
    if ($match || $first)
        {
	$EB = $_;
	$_ = "";
	for ($ctr = 0; ! (eof() || /[\041-\177]/); $ctr++)
            {
            $_ = <>;
	    $headers [ctr] = $_;
            }
	if (/^[^ \t\r\n:]+: /)
	    {
	    print FOLDER "From dummy Wed Feb  29 12:12:12 1990\n";
	    print FOLDER "X-EB: " . $EB ;
	    $hang = 0;
	    }
	else
	    {
	    print FOLDER $EB;
	    for ($ctr2 = 0; $ctr2 < ctr - 1; $ctr2++)
		{
		print FOLDER $headers [ctr2];
		}
	    $hang = 1;
	    }
        }
    if (/^- /)
	{
	$_ = substr ($_, 2);
	}
    print FOLDER $_;
    $first = 0;
    }
close (FOLDER);
exec ("elm -f /tmp/dig$$ <&2 ; /bin/rm -f /tmp/dig$$");
