diff --git a/remove-spam-high-confidence-maildir.plx b/remove-spam-high-confidence-maildir.plx index 159b4fc..e2e94b1 100644 --- a/remove-spam-high-confidence-maildir.plx +++ b/remove-spam-high-confidence-maildir.plx @@ -23,12 +23,12 @@ use warnings; use Mail::Header; #use File::Copy; -if (@ARGV < 3) { - print STDERR "usage: $0 \n"; +if (@ARGV < 3 or @ARGV > 4) { + print STDERR "usage: $0 []\n"; exit 1; } -my($MAILDIR_FOLDER, $DSPAM_PROB_MIN, $DSPAM_CONF_MIN) = @ARGV; +my($MAILDIR_FOLDER, $DSPAM_PROB_MIN, $DSPAM_CONF_MIN, $COUNT_ONLY) = @ARGV; my($total, $countDeleted) = (0, 0); @@ -68,8 +68,10 @@ MAIL: foreach my $dir (@msgDirs) { if ($dspamVal{Confidence} >= $DSPAM_CONF_MIN and $dspamVal{Probability} >= $DSPAM_PROB_MIN) { $countDeleted++; - warn "unable to unlink $dir/$file : $!" - unless unlink("$dir/$file") == 1; + if (defined $COUNT_ONLY and $COUNT_ONLY) { + warn "unable to unlink $dir/$file : $!" + unless unlink("$dir/$file") == 1; + } } close MAIL_MESSAGE; }