MBOX buster
- April 5th, 2007
- Write comment
I recently joined the DSM-ECU list on yahoo groups. When I did I wanted something to download the archives for offline reading. I found such a thing in yahoo2mbox. Unfortunately, I don’t read mail in mbox format. I wrote this perl snippet to bust the messages out into maildir style files. It’s nothing terribly fancy, but it works a treat. Feel free to use it for whatever … Or not … Whatever
#!/usr/bin/perl -w
$| = 1;
my $filename;
while(
if(/^From /) {
close(FILE);
$goodfile = 0;
while($goodfile == 0) {
$filename = time() . "." . int(rand(65535)) . "." ' `hostname`;
if( -f $filename) {
# ERROR: $filename already exists
next;
}
else {
open(FILE, ">>$filename") or die("Unable to open $filename: $!");
$goodfile = 1;
}
}
next;
}
print(FILE $_);
}
Enjoy
… End of Line …