#!/bin/perl -w
#########################################
#split_mbox.pl
#
#This script is desined to split an mbox
#file into individual message files.
#########################################
my $infile="/path/to/infile";
my $outdir="/path/to/outdir";
my $fcnt=1;
my @fcontents;
open(INFILE, "$infile") || die "Can't open $infile: $!";
@fcontents=<INFILE>;
close(INFILE);
foreach $line(@fcontents) {
my $outfile="$outdir/$fcnt";
print "$outfile\n";
if($line =~ /^From /) {
print "$line\n";
close(WRITE);
$fcnt++;
$outfile="$outdir/$fcnt";
open(WRITE, ">$outfile") || die "Can't open $outfile: $!";
print WRITE $line;
} else {
print WRITE $line;
}
}
Use it or not, as you like...