The Email::* modules are quite useful. I wanted to merge a couple of mboxes together and put the result in date received order. It turned out to be dead simple with the Email modules.
#!perl -w
use strict; use Email::Simple; use Email::Folder; use Email::Date; use Email::LocalDelivery; use Getopt::Long;
# valid options are --first_mbox --second_mbox --out_mbox my ($first, $second, $out); unless(GetOptions('first_mbox=s' => \$first, 'second_mbox=s' => \$second, 'out_mbox=s' => \$out, )) { die("Error with GetOptions: $!\n"); }
my $first_mbox = Email::Folder->new($first); my $second_mbox = Email::Folder->new($second);