Okay;

I am sure that someone out there has done this before - I *think* I am
on the right track.

I have a directory full of emails. What I would like to do is read
each file in, then parse them into a CSV style file.

Example:


#!/usr/bin/perl

use warnings;
use strict;

open FILE , "/home/gmillard/SentMail/YourSatSetup.txt" or die $!;
my $linenum =1;

while (<FILE>) {
        print "|", $linenum++;
        print"$_" ;
}

Produces the following.

|1From - Sun Feb 21 11:40:01 2010
|2X-Mozilla-Status: 0001
|3X-Mozilla-Status2: 00000000
|4X-Gmail-Received: 58fa0ec68ca9975c1d187ceadc0ad3aeb1026134
|5Received: by 10.48.212.6 with HTTP; Fri, 17 Nov 2006 12:52:26 -0800
(PST)
|6Message-ID:
<234ff75a0611171252x3ea2facdw55cd81ec3a185...@mail.gmail.com>
|7Date: Fri, 17 Nov 2006 15:52:26 -0500
|8From: "xxxxxxxxxxxxxxxxxxxxxxxx>
|9To: xxx...@bell.blackberry.net
|10Subject: Your satellite set up. . From an article that i read.
|11MIME-Version: 1.0
|12Content-Type: text/plain; charset=ISO-8859-1; format=flowed
|13Content-Transfer-Encoding: 7bit
|14Content-Disposition: inline
|15Delivered-To: xxxxxxxxxxxxxxxxxxxxxx
|16
|17Hi Andrew;
|18I read an article about you a while back about your MythTV and VOip
|19setup. Would you mind if i asked you some tech questions ? I am
very
|20intrigued.
|21Thanks
|22Glen xxxxxxxxxx
|23xxxxxxxxxxxxx


I have hundreds of emails in this directory. I would like to parse
them into a single file where each comma separated/tab separated field
is a line from the email.

So, the first line of the CSV file is
|1From - Sun Feb 21 11:40:01 2010|2X-Mozilla-Status: 0001|3X-Mozilla-
Status2: 00000000|4X-Gmail-Received:
58fa0ec68ca9975c1d187ceadc0ad3aeb1026134
<truncated>

and each subsequent line is the next email and so forth.

Any words of wisdom?

Thanks much.

Glen


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to