in reply to Spliting an mbox file

I'm not so sure Flech is right about the file not starting with a "From " line, I think it's just not starting with a "From ... 2003" line. The way I read what you're doing, you're using something like
while (<FILE>) { if (/^From .+ 2003/) { $mails[$#mails + 1] = $_; } else { $mails[$#mails] .= $_; } print $OUT, @mails; }
The else tries to add lines to an array bin that the "From " test has not created, because it hasn't yet gotten to the section of the emails from 2003 that you want. Try something like
while (<FILE>) { if (/^From /) { if (/2003/ || $mailsStarted) { $mails[$#mails + 1] = $_; $mailsStarted = 1; } } elsif ( $mailsStarted ) { $mails[$#mails] .= $_; } print $OUT, @mails; }

Note that you will get some non-2003 emails that come after the first 2003 email, but that should be ok.