in reply to Spliting an mbox file
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 likewhile (<FILE>) { if (/^From .+ 2003/) { $mails[$#mails + 1] = $_; } else { $mails[$#mails] .= $_; } print $OUT, @mails; }
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.
|
|---|