in reply to Parsing email files, what are the best modules ?
And the output so far...#C:\Perl\bin\Perl.exe -w use strict; use IO::File; use Data::Dumper; use Mail::Box; # Load mail list my $MailList = load_mail_list('./list25B6.txt'); print Dumper($MailList); # Load folder list my $MailFolder = load_mail_folders('./hierarch.txt'); print Dumper($MailFolder); # Parse folder files foreach (values %{$MailFolder}) { parse_mail_folder($_); } sub parse_mail_folder { # to be completed when I get back home... } sub load_mail_list { my $filename = shift; my $f = new IO::File $filename, "r" or die "Can not open mail list +"; my %mlist; # load the header chomp($mlist{title} = <$f>); chomp($mlist{sender} = <$f>); chomp($mlist{nosig} = <$f>); # load the rest of the email addresses my %MailAddress; while (<$f>) { chomp; my ($name, $email) = /^(.*)\s+<(.*)>$/; next if $email eq ''; $MailAddress{$email} = $name; } $mlist{mlist} = \%MailAddress; return \%mlist; } sub load_mail_folders { my $filename = shift; my $f = new IO::File $filename, "r" or die "Can not open mail fold +er list"; my %mbox; while (<$f>) { chomp; next unless ( $_ ne '' and m/^0,0,/ ); s/"//g; my @fld = split /,/; my $folder = (split /:/, $fld[2])[2]; # capture 3rd field $mbox{$fld[-1]} = "D:/Pmail/mail/$folder.PPM"; # full path to +mboxes } return \%mbox; }
$VAR1 = { 'title' => '\\TITLE Email Distribution', 'nosig' => '\\NOSIG Y', 'mlist' => { 'jbarker@someotherdomain.org' => 'David & Jan B +arker', 'johnarnold@somedomain.com' => 'John & Jenny Ar +nold' }, 'sender' => '\\SENDER Peter Rabbitt <peterr@example.com>' }; $VAR1 = { 'Main' => 'D:/Pmail/mail/FOL07093.PPM', 'Microsoft' => 'D:/Pmail/mail/FOL024EB.PPM', 'Sent' => 'D:/Pmail/mail/FOL04816.PPM' };
|
|---|