This breaks down for many messages that have 2 "From"'s.  Most messages start with a 
From not followed by a colon that is the envelope leader and include a From: (notice 
followed by a colon) that is in the message headers.

I would suggest you not reinvent the wheel and check out the many modules for handling 
mail related stuffs on CPAN. Mail-tools and Mail::Box in particular.

http://danconia.org


------------------------------------------------
On Fri, 13 Dec 2002 11:08:39 -0600, "Wagner, David --- Senior Programmer Analyst --- 
WGO"        <[EMAIL PROTECTED]> wrote:

>       Here is a start. I put to an array, but you could write to a file:
> #!perl -w
> my @MyMail = ();              # hold email
> my $MyHoldMail = '';  # use to build each email msg
> my $In = 0;                   # count of lines
> my $MyProc = 0;               # ready to process or not
> 
> while ( <DATA> ) {
>      chomp;                   # remove \n
>      $In++;                   # count of lines
>      if ( /^\sFrom\s/i ) {            # if at start of line
>         push(@MyMail, $MyHoldMail) if ( $MyHoldMail ne '' );  # if something
> in MyHoldMail, push
>         $MyHoldMail = '';             # clear the hold area
>         $MyProc = 1;                  # set process flag
>       }
>     next if ( ! $MyProc );            # if haven't hit a from to signify
> start of processing, bypass
>     $MyHoldMail .= $_ . "\n";         # concatenate together
>  }
> push(@MyMail, $MyHoldMail) if ( $MyHoldMail ne '' ); # flush last item if
> any
> my $MyCnt = 1;                                # msg count
> foreach ( @MyMail ) {
>     printf "\nMsg Nbr: %5d\n%-s",  $MyCnt++, $_ . '*'x65 . "\n";
>  }
> 
> __DATA__
> <for testing purposes, put your email info here for processing>
> 
> Wags ;)
> 
> -----Original Message-----
> From: Marcelo [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 13, 2002 08:54
> To: [EMAIL PROTECTED]
> Subject: Split a text file 
> 
> 
> Hi everybody ...
> 
> When I receive mail.. I can see it like a plain text file under 
> /var/spool/mail/marcelo where all the messages are concateneted one 
> after the other .... here is an example :
> 
>  From [EMAIL PROTECTED]  Fri Dec  6 17:56:19 2002
> Return-Path: <[EMAIL PROTECTED]>
> Received: from insight.incubadoras.org (insight.incubadoras.org [127.0.0.1])
>         by insight.incubadoras.org (8.12.5/8.11.6) with ESMTP id 
> gB6MuJ56001698
>         for <[EMAIL PROTECTED]>; Fri, 6 Dec 2002 17:56:19 -0500
> Received: (from root@localhost)
>         by insight.incubadoras.org (8.12.5/8.12.5/Submit) id gB6MuJDC001696
>         for [EMAIL PROTECTED]; Fri, 6 Dec 2002 17:56:19 -0500
> Date: Fri, 6 Dec 2002 17:56:19 -0500
> From: root <[EMAIL PROTECTED]>
> Message-Id: <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Prueba
> Status: O
> 
> aqui va el msg.
> 
>  From [EMAIL PROTECTED]  Thu Dec 12 13:11:55 2002
> Return-Path: <[EMAIL PROTECTED]>
> Received: from jupiter.espoltel.net (jupiter.espoltel.net [xxx.xxx.xxx.xxx])
>         by insight.incubadoras.org (8.12.5/8.11.6) with ESMTP id 
> gBCHNbKT013907
>         for <[EMAIL PROTECTED]>; Thu, 12 Dec 2002 12:23:37 -0500
> Received: from pablo ([xxx.xxx.xxx.xxx])
>  by jupiter.espoltel.net (8.12.5/8.11.6) with SMTP id gBCHWVOS011823
>         for <[EMAIL PROTECTED]>; Thu, 12 Dec 2002 12:32:34 -0500
> From: "Pablo Mora" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Subject: land
> Date: Thu, 12 Dec 2002 12:16:57 -0500
> 
> Another e-mail body ...
> 
> I have a script that take the headers of one message ... but it doesn't 
> works with this file when there are more than one file concateneted ..so 
> I need to split the message into n parts where each part is a single 
> message based in the word "From " that starts every mesage in this file 
> ....How???...
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> **********************************************************
> This message contains information that is confidential
> and proprietary to FedEx Freight or its affiliates.
> It is intended only for the recipient named and for
> the express purpose(s) described therein.
> Any other use is prohibited.
> ****************************************************************
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to