#!/afs/athena/contrib/perl/p

# Filter for use in with olcr "mail" command and "vi" editor.  Use:
# map  1G!Gofilt.pl

$tofield = <STDIN>;

$tofield =~ /<([^@]*)@Athena.mit.edu>/i;

$user = $1;

print "From: Calvin Clark <ckclark@mit.edu>\n";
print $tofield;

while (<STDIN>) 
{
    next if /^cc:/;
    print;
    if (/^--------/)
    {
	local ($printit);

	print "Sorry your question was not answered while you were logged in.\n";
	print "You asked:\n\n";
	
	open (OREPLAY, "oreplay $user |") || die $!;
	while (<OREPLAY>)
	{
	    last if /^Machine info:$/;
	    print "> ", $_ if $printit;
	    $printit = 1 if /^Question:$/;
	}
    }
}

print <<"EOF"
I hope this helps and thanks for using OLC.

-Calvin
--
Calvin Clark <ckclark@mit.edu>
SIPB Volunteer Consultant
EOF
