use strict; use warnings; use Mail::MboxParser; use Storable; my $mbox = shift; # name of the mailbox file my $mb = Mail::MboxParser->new( $mbox ); $mb->make_index; my @index; # Build index. I'm adding message position and subject # into index, but you can add also other fields. for ( 0 .. $mb->nmsgs - 1 ) { push @index, [ $_, $mb->get_pos($_), $mb->get_message($_)->header->{subject} ]; } # save index into file store \@index, "$mbox.idx";