#!/usr/local/bin/perl

$DraftDir = '/home/R10E/gcheng/tmp/javascript';
$inbox = "$DraftDir/inbox";
#$inbox = "$DraftDir/tmp";
#$Draftfile = "$DraftDir/javascript.9601";
($Draftfile) = @ARGV;
$ENV{"PATH"} = "/bin:/usr/local/bin:/usr/local/mh:.";

$count = 0;
&draft_parse($inbox);
print "\n**** Total $count mails handled.****\n";
exit 0;

#--------------------------------------------------------------------------
# Usage:	&draft_parse();
# Action:	parse current draft and move to specific folder
#--------------------------------------------------------------------------
sub draft_parse	{
local($draft) = @_;
local($p) = ('draft_parse');

open(FILE,$Draftfile) || die "Error in $p: Open $draft";
$state = 'head';
while(<FILE>)	{
	chop;
	$input_line = $_;
	if (/^From owner-javascript\@obscure.org/) {
		close(msg_file);
		$count++;		
		open(msg_file,">$draft/$count");
		print "######$draft/$count#####\n";
	}
	else 
	{print msg_file "$input_line\n";}
}
close(FILE);
close(msg_file);
return 0;
}
