# This is a perl thing
# Mess with the first line only

$homedir = $ENV{'HOME'};
$user = $ENV{'USER'};	
$mail = $ENV{'MAIL'};

$run = "\"|$homedir/.remail/slocal.pl $user" ;
#$append = "|$homedir/.remail/append.pl" ;
$append = ">>" ;

# Now we decide what to throw on the end

# With commas
# A file

while(<>)
{
    if ( /^(\/.*),(.*)$/ )
    {
	print "$run $append $1\",$2\n" ;
    }
    else
    {
	# Address
	if ( /^([A-Za-z0-9][^,]*),(.*)$/ )
	{
	    print "$run |$homedir/.remail/bounce $1\",$2\n";
	}
	else
	{
	    # Something with a pipe
	    if ( /^[^\|]*\|(.*)$/ )
	    {
		print "$run |$1\n" ;
	    }
	    else
	    {
		if ( /^(\/.*)$/ )
		{
		    print "$run $append $1\"\n";
		}
		else
		{
		    if ( /^([A-Za-z0-9].*)$/ )
		    {
			print "$run |$homedir/.remail/bounce $1\"\n";
		    }
		    else
		    {
			if ( /^[ \t]*$/ )
			{
			    print "$run $append $mail\"\n";
			}
		    }
		}
	    }
	}
    }
    last;
}

print <>;
