#!/usr/local/bin/perl -w
#-*-Perl-*-
#
# $Id: make-reply.pl,v 1.1 1997/09/24 17:44:57 pgreene Exp $
#
# Take an incoming message and generate a "reply" message which
# includes the incoming headers, an autoreply message (specified as an
# argument), and the appropriate "references-block".
#

if (! $#ARGV == 0) {
	die "Usage: make-reply.pl <autoreply-file>";
}

$replyname = $ARGV[0];
open (REPLY,"< $replyname") || 
	die "Couldn't open autoreply $replyname for reading.\n";

# print headers, until first blank line; also save a copy for later use

$headers = "";
while (<STDIN>) {
    $headers .= "> " . $_;
    print;
    last unless /./;
}

# include autoreply
while (<REPLY>) {
	print;
}

# print reference block info
print "\nReference:\n\n  [begin reference inclusion]\n\n";

# print escaped headers & body of message

print $headers;

while (<STDIN>) {
	print "> $_";
}

print "\n  [end reference inclusion]\n";
