# Call slocal recursivelly, first checking the message body for the
# pasting token "::" and appending any following lines before a blank
# line to the header.

  # First read in the whole header.

while (<>) {
	s/[ \t\r]*$// ;
        last if /^$/ ;
        $header .= $_ ;
}

  # We have just read the last line in the header.
  # Now we check to see if there is a pasting operator.

while (<>) {
  last unless /^[ \t\r]*$/ ;
}

if ( /^::[ \t\r]*$/ ) {
        while (<>) {
		s/[ \t\r]*$// ;
                last if /^$/ ;
                $header .= $_ ;
        }
} else {
        # There is either an empty body or no pasting operator
        #   Thus exit with a return code of 1 to indicate that
        #   the mail has not been delivered.
                exit( 1 );
}

# There was a header pasting operator.
#   So we open 'slocal.pl' as a pipe, effectively redelivering the mail
#   back to ourselves.

#open( OUTPUT, ">foo" ) ;
open( OUTPUT, "| slocal.pl");
select( OUTPUT ) ;

# Now just print out the message

print $header ;
print "\n" ; 
print <>;







