Click here to get back home

Which split delimiter to use for mailbox

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Which split delimiter to use for mailbox Bart Van der Donck 03-13-2008
Posted by Bart Van der Donck on March 13, 2008, 4:41 am
Please log in for more thread options
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 jeff@domain.com Wed Mar 12 19:14:17 2008
[headers]
[blanc line]
[body]
[blanc line]
From john@domain.com Wed Mar 12 19:50:11 2008
[headers]
[blanc line]
[body]
[blanc line]
From kevin@domain.com 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 xx@xx.xx" itself.

Thanks,

--
Bart

Posted by Martijn Lievaart on March 13, 2008, 9:48 am
Please log in for more thread options
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 jeff@domain.com Wed Mar 12 19:14:17 2008 [headers]
> [blanc line]
> [body]
> [blanc line]
> From john@domain.com Wed Mar 12 19:50:11 2008 [headers]
> [blanc line]
> [body]
> [blanc line]
> From kevin@domain.com 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 xx@xx.xx" 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

Posted by ccc31807 on March 13, 2008, 10:13 am
Please log in for more thread options
> 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 j...@domain.com Wed Mar 12 19:14:17 2008
> [headers]
> [blanc line]
> [body]
> [blanc line]
> From j...@domain.com Wed Mar 12 19:50:11 2008
> [headers]
> [blanc line]
> [body]
> [blanc line]
> From ke...@domain.com 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 x...@xx.xx" 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

Similar ThreadsPosted
split by word using | as delimiter December 20, 2005, 5:02 pm
Split, variable delimiter February 21, 2006, 1:11 pm
Mailbox-style directory hashing October 31, 2006, 6:40 pm
Parsing a file with a known delimiter November 11, 2005, 7:29 pm
Calculations with ',' as decimal delimiter March 23, 2006, 3:21 pm
parsing a tab delimited or CSV, but keep the delimiter March 22, 2007, 4:04 pm
parse with multiple delimiter April 25, 2007, 3:40 pm
Matching escaped delimiter chars November 28, 2005, 9:21 pm
Processing multiple delimiter files March 13, 2006, 4:47 pm
path delimiter in windows platform("/" could change to "\"?) September 26, 2004, 12:10 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap