in reply to Splitting email inbox text into separate messages

You do not mention what format you are trying to deal with. Are you trying to read directly from a Unix mail spool? Are you trying to read a file in unix mbox format? Are you an Emacs user trying to read the Babyl formatted files produced by Rmail? Or, perhaps, is it one message per file with an index, and you need to parse the index and get rid of the headers? Or, is this for Outlook (Express) on a Windows system, using a completely different beast?

I can't tell you how to parse all of those formats off the top of my head. I can tell you that Abigail's suggestion of splitting on From: headers will work if you're using mbox format (and I think Babyl), however it will fail if someone includes an e-mail to you with the string "From:" at the beginning of a line. (Which probably isn't a big concern).

However, the key to all of this is the format. If you know what format the program you are trying to read from is using, you can look up the specifications online. There's probably also a module on CPAN available to parse it so you don't have to code. (And that module will possibly even handle things like indexes.)


Want to support the EFF and FSF by buying cool stuff? Click here.
  • Comment on Re: Splitting email inbox text into separate messages