From a50773ca257dee9ac75d4ce8762c1184b1ea5bd4 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Tue, 30 Nov 2004 11:03:43 +0000 Subject: [PATCH] some comments. I know it's not perlish, but I vomit perl, and I only use it here, because it's convenient --- scripts/mailman/mhonarc_by_month.pl | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/scripts/mailman/mhonarc_by_month.pl b/scripts/mailman/mhonarc_by_month.pl index efbbefb..c1b41d1 100755 --- a/scripts/mailman/mhonarc_by_month.pl +++ b/scripts/mailman/mhonarc_by_month.pl @@ -1,9 +1,19 @@ #! /bin/perl -w # use strict; - +################################################################################ +# the RCFILE is the first arg +# my $rcfile = shift; +# +################################################################################ +# the list prefix is the second one +# my $list = shift; +# +################################################################################ +# CONSTANTS +# my $spool = "/var/spool/platal/archives/"; my $tmpbox = "mytmpbox.mbox"; @@ -20,25 +30,38 @@ $conv{'Sep'} = "09"; $conv{'Oct'} = "10"; $conv{'Nov'} = "11"; $conv{'Dec'} = "12"; - +# +################################################################################ +# local vars +# my $mail = ""; my $line = ""; my $odir = ""; my $y = ''; my $m = ''; - +# +################################################################################ while(<>) { $line = $_; + + ## + ## Do we start a new mail ? + ## if($line =~ /^From +[^@ ]*@[^@ ]* +[a-z]* +([a-z]*) +\d* +\d*:\d*:\d* +(\d*)$/i) { if ($conv{$1} ne $m || $y ne $2) { if($odir) { + ## + ## If we are here, then we just finished a month. + ## -> we close the file, and exec mhonarc on the stuff + ## close FILE; $odir = $spool.$list."/$y/$m"; system("mkdir -p $odir") unless (-d $odir); system("mhonarc -add -outdir $odir -rcfile $rcfile $tmpbox"); } else { + # dummy init $odir = 1; } @@ -47,6 +70,7 @@ while(<>) { open FILE,"> $tmpbox"; } } + print FILE $line; } -- 2.1.4