in reply to Spliting an mbox file
I'd agree with Fletch to some extent but I would recommend Email::Folder to read the mailbox and Email::LocalDelivery to 'deliver' it to the new mailbox:
use strict; use warnings; + use Email::Folder; use Email::LocalDelivery; + my $count = 0; my $box_size = 100; + my $boxbase = '/home/jonathan/tmp/testmail/spam'; + my $box = Email::Folder->new('/home/jonathan/mail/spam'); while ( my $mail = $box->next_message ) { my $newbox = $boxbase . int($count++ / $box_size); Email::LocalDelivery->deliver($mail->as_string(),($newbox)); }
/J\
|
|---|