some comments.
authorx2000habouzit <x2000habouzit>
Tue, 30 Nov 2004 11:03:43 +0000 (11:03 +0000)
committerx2000habouzit <x2000habouzit>
Tue, 30 Nov 2004 11:03:43 +0000 (11:03 +0000)
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

index efbbefb..c1b41d1 100755 (executable)
@@ -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;
 }