Problem: Mozilla mailbox is way to big (800MBs).
Solution: Split it up.
#!/usr/bin/perl
############
# Splits Mozilla style Inboxes into smaller ones (max size = maxMailboxSize)
# use: ./splitMozilla <mailbox name>
# output: mailbox0 [mailbox1] [mailbox2] ...
############
$maxMailboxSize = 104857600;
$mailboxNumber = 0;
open OUTPUTFILE, ">mailbox$mailb oxNumber";
while(<>) {
if(/^From /) {
if((stat(OUTPUT FILE))[7] > $maxMailboxSize ) {
close OUTPUTFILE;
$mailboxNumber ++;
open OUTPUTFILE, ">Inbox$mailbox Number";
}
}
print OUTPUTFILE $_;
}
Problem: It's not working. It's creating mailbox0, writes about 1.9MBs, then
the system runs out of memory, which shouldn't happen. What I'm basically
trying to do is search for a new message, check if the outputfile is over
100MBs, if it is, create a new one, if it's not, then write the message to
outputfile. Any ideas?
-Chris Mika
cmika@-takethisout-25thandclement. com
Solution: Split it up.
#!/usr/bin/perl
############
# Splits Mozilla style Inboxes into smaller ones (max size = maxMailboxSize)
# use: ./splitMozilla <mailbox name>
# output: mailbox0 [mailbox1] [mailbox2] ...
############
$maxMailboxSize = 104857600;
$mailboxNumber = 0;
open OUTPUTFILE, ">mailbox$mailb oxNumber";
while(<>) {
if(/^From /) {
if((stat(OUTPUT FILE))[7] > $maxMailboxSize ) {
close OUTPUTFILE;
$mailboxNumber ++;
open OUTPUTFILE, ">Inbox$mailbox Number";
}
}
print OUTPUTFILE $_;
}
Problem: It's not working. It's creating mailbox0, writes about 1.9MBs, then
the system runs out of memory, which shouldn't happen. What I'm basically
trying to do is search for a new message, check if the outputfile is over
100MBs, if it is, create a new one, if it's not, then write the message to
outputfile. Any ideas?
-Chris Mika
cmika@-takethisout-25thandclement. com
Comment