in reply to Help appending data based on location

Parsing email is not a trivial task. Maybe using a CPAN library might be safer. I can't recommend anything (haven't used one yet), but someone else might have an idea what to use. I found http://search.cpan.org/~markov/MailTools-2.07 with a quick search, check out the demos

What you want is a parser. For simple line oriented tasks a FSM (Finite State Machine) is often a good practical solution that keeps the complexity in check. In Re^3: How to parse a text file there is a simple example of a FSM. What you do with $lineBufferStatus is already a simple FSM. But you would need at least another state that says "I'm at the To-line now"

By the way to check if an array is empty, int() is rather unusual. Well TMTOWTDI, but the following lines are equivalent and the last of them is commonly used and as safe as your version

if (int(@array)>0) { if (scalar(@array)>0) { if (@array>0) { if (@array) {

Replies are listed 'Best First'.
Re^2: Help appending data based on location
by Anonymous Monk on Jan 25, 2011 at 21:31 UTC
    Hi Thanks for the reply. The only problem with using a cpan mail module is that it's not always in a mail format. What I need to do in only extract certain data from the message files not handle actual mail.