3 # perl script to convert mbox file to files in a new MH directory
4 # aka another mbox -> MH conversion tool
6 # Fred Marton <Fred.Marton@uni-bayreuth.de>
8 # Note: Running this with the -w flag generates the following warnings:
9 # Scalar value @word[1] better written as $word[1] at /path/to/convert_mbox.pl line 54
10 # Scalar value @word[0] better written as $word[1] at /path/to/convert_mbox.pl line 56
11 # Making these changes requires further changes in the script
12 # that results in much longer run-times.
14 # Copyright © 2003 Fred Marton
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License
18 # as published by the Free Software Foundation; either version 2
19 # of the License, or (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
31 # check for both arguments
32 &usage if ($#ARGV < 1);
35 # check to make sure there isn't something named MH already
37 die (" The directory \"$mh\" already exists. Exiting.\n");
46 while ($line = <IN>) {
47 # check for the beginning of an e-mail
48 @word = split(/ +/m,$line);
49 # some lines might start with "From ", so check
50 # to see if the seventh word is a year
53 # ignore the MAILER-DAEMON message from pine
54 if (@word[1] ne "MAILER-DAEMON") {
55 # start a new file, assuming $year is > 1970
56 if (@word[0] eq "From" && $year > 1970) {
59 open (OUT, ">$mh/$i");
71 print "\n If it isn't there already, please move the directory \"$mh\"\n"
72 . " into your MH directory and rebuild your folder tree.\n\n";
76 die ( " usage: convert_mbox.pl MBOX MH_DIR\n");