From 074f2979e8991eab0b69a5cce5930795b3a7563c Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sun, 21 Nov 2010 12:10:22 -0500 Subject: [PATCH] Count only option, if you just want to know how many would be deleted. --- remove-spam-high-confidence-maildir.plx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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; }