mail-uplift -> mbox
authorTony Finch <dot@dotat.at>
Fri, 28 Nov 2014 18:45:33 +0000 (18:45 +0000)
committerTony Finch <dot@dotat.at>
Fri, 28 Nov 2014 18:45:33 +0000 (18:45 +0000)
ipreg-mail-uplift [new file with mode: 0755]

diff --git a/ipreg-mail-uplift b/ipreg-mail-uplift
new file mode 100755 (executable)
index 0000000..808363f
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+# reformat from MH to mbox
+
+use warnings;
+use strict;
+
+sub shite { die "ipreg-mail-uplift: @_: $!\n"; }
+sub shit  { die "ipreg-mail-uplift: @_\n"; }
+
+for my $f (<ipreg-mail/Institutions/*>) {
+  next unless -f $f;
+  print "processing $f\n";
+  open my $in, '<', $f
+    or shite "open < $f";
+  my @f = map s{^[+][+][+]\s+
+               ([a-z]+[0-9]*[ ] # user
+               [A-Z][a-z][a-z][ ] # day
+               [A-Z][a-z][a-z])\s+ # mon
+               ([0-9]+)\s+ # date
+               ([0-9][0-9]:[0-9][0-9]:[0-9][0-9][ ] # time
+               [A-Z][A-Z][A-Z][ ] # zone
+               [12][0-9][0-9][0-9])\s*$ # year
+              }{sprintf "From %s %2d %s\n", $1, $2, $3}xe,
+              <$in>;
+  open my $out, '>', "$f.new"
+    or shite "open > $f.new";
+  print $out @f;
+}