I'm assuming you don't want to load the entire mailbox into memory at once, since spam can make even a few days of email pretty large. The following is a line by line interpreter of the format you gave, with test data:
use strict; use warnings; my $c; my $text = <DATA>; while (<DATA>) { if (index($_, 'From') == 0) { process($text); $text = $_; } else { $text .= $_; } } process($text); print "\n$c messages total\n"; sub process { # Do whatever you do to each message... $c++; print $_[0], "\n"; } __DATA__ From ???@??? Wed Feb 02 11:47:05 2000 Message-ID: <38968A8A.DBB01A7@earthlink.net> From: Someone <beepbeep@earthlink.net> X-Mailer: Mozilla 4.6 [en] (Win98; U) Message 1 From ???@??? Wed Feb 02 11:47:05 2000 Message-ID: <38968A8A.DBB01A7@earthlink.net> From: Someone <beepbeep@earthlink.net> X-Mailer: Mozilla 4.6 [en] (Win98; U) Message 2
Rather kloodgey, but it works. Just replace DATA with whatever filestream has the email file.

In reply to Re: Mailbox spliting and storing each message! by TedPride
in thread Mailbox spliting and storing each message! by cookiez

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.