Which split delimiter to use for mailbox

Discussion in 'Perl Misc' started by Bart Van der Donck, Mar 13, 2008.

  1. Hello,

    I'm reading an email inbox file in Perl like /usr/boxes/mydomain.com/
    info. This file consists of 1 or more mails that are waiting to be
    delivered. Which mechanism is safe enough to split this file in order
    to know the number of waiting emails ?

    The format looks like this:

    From Wed Mar 12 19:14:17 2008
    [headers]
    [blanc line]
    [body]
    [blanc line]
    From Wed Mar 12 19:50:11 2008
    [headers]
    [blanc line]
    [body]
    [blanc line]
    From Wed Mar 12 21:47:07 2008
    [headers]
    [blanc line]
    [body]

    I don't understand how Perl can split this input reliably, so that it
    knows where a next mail starts. I mean, every message could also
    contain blanc lines or "From " itself.

    Thanks,

    --
    Bart
     
    Bart Van der Donck, Mar 13, 2008
    #1
    1. Advertising

  2. On Thu, 13 Mar 2008 01:41:37 -0700, Bart Van der Donck wrote:

    > Hello,
    >
    > I'm reading an email inbox file in Perl like /usr/boxes/mydomain.com/
    > info. This file consists of 1 or more mails that are waiting to be
    > delivered. Which mechanism is safe enough to split this file in order to
    > know the number of waiting emails ?
    >
    > The format looks like this:
    >
    > From Wed Mar 12 19:14:17 2008 [headers]
    > [blanc line]
    > [body]
    > [blanc line]
    > From Wed Mar 12 19:50:11 2008 [headers]
    > [blanc line]
    > [body]
    > [blanc line]
    > From Wed Mar 12 21:47:07 2008 [headers]
    > [blanc line]
    > [body]
    >
    > I don't understand how Perl can split this input reliably, so that it
    > knows where a next mail starts. I mean, every message could also contain
    > blanc lines or "From " itself.


    The delimiter is '\n\nFrom'. It it occurs in the body it should be
    escaped (by putting a '>' before the 'From' IIRC).

    HTH,
    M4
     
    Martijn Lievaart, Mar 13, 2008
    #2
    1. Advertising

  3. Bart Van der Donck

    ccc31807 Guest

    On Mar 13, 4:41 am, Bart Van der Donck <> wrote:
    > Hello,
    >
    > I'm reading an email inbox file in Perl like /usr/boxes/mydomain.com/
    > info. This file consists of 1 or more mails that are waiting to be
    > delivered. Which mechanism is safe enough to split this file in order
    > to know the number of waiting emails ?
    >
    > The format looks like this:
    >
    > From Wed Mar 12 19:14:17 2008
    > [headers]
    > [blanc line]
    > [body]
    > [blanc line]
    > From Wed Mar 12 19:50:11 2008
    > [headers]
    > [blanc line]
    > [body]
    > [blanc line]
    > From Wed Mar 12 21:47:07 2008
    > [headers]
    > [blanc line]
    > [body]
    >
    > I don't understand how Perl can split this input reliably, so that it
    > knows where a next mail starts. I mean, every message could also
    > contain blanc lines or "From " itself.
    >
    > Thanks,
    >
    > --
    > Bart


    Count the '^Froms'. That will give you an accurate count of the number
    of separate messages and you don't need a delimiter.

    CC
     
    ccc31807, Mar 13, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Fox

    Delimiter Split

    Mark Fox, Aug 11, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    3,346
    Chris R. Timmons
    Aug 11, 2003
  2. Kevin Spencer
    Replies:
    5
    Views:
    1,226
    =?Utf-8?B?UENL?=
    Jan 21, 2004
  3. Replies:
    9
    Views:
    374
    Paul McGuire
    Nov 16, 2006
  4. Replies:
    18
    Views:
    5,148
    Michael Jung
    Aug 11, 2013
  5. rewonka
    Replies:
    10
    Views:
    690
    M.-A. Lemburg
    Mar 19, 2009
Loading...

Share This Page