Gossamer Forum
Home : General : Perl Programming :

extracting message blocks using perl

Quote Reply
extracting message blocks using perl
Hello,

I am a new programmer in perl. Could you please tell me how to extract message blocks from a log file, using perl? I would really appreciate your help.

Thank you,

Priya.
Quote Reply
Re: [priyarak] extracting message blocks using perl In reply to
Can you give us a sample of the log file with what you are tying to extract?

- wil
Quote Reply
Re: [Wil] extracting message blocks using perl In reply to
Hi,

Thank you very much for your reply. I really appreciate your help.

The sample of log file is as follows.

Using perl, I need to extract message-id and the corresponding message alone, from the log file! Could you please tell me how I can do that?

The sample of log file is as follows. --

From - Tue Apr 08 08:07:24 2003

Return-Path: <AC_del_monitor@arnet.com.ar>

Errors-To: <AC_del_monitor@arnet.com.ar>

Subject: Por la Reparacion del MONITOR

Date: Mon, 7 Apr 2003 22:35:35 -1200

MIME-Version: 1.0

Errors-To: <AC_del_monitor@arnet.com.ar>

x-esmtp: 0 0 1

Message-ID: <381166-2200342810353590@pc>


X-Mozilla-Status: 8001

X-Mozilla-Status2: 00000000

X-UIDL: 46963

RECICLAMOS el MONITOR de su PC

d=E1ndole otros 4 a=F1os de vida =FAtil=2E=2E=2E

=20

>>>> POR SOLO $ 49 !!! <<<<

=20

ATENCION EMPRESAS U ORGANISMOS OFICIALES, =A1=A1 NO GASTEN UN SOLO PESO !!=

p=E1guenos con parte de los monitores que nos entregan para reciclar

(transforme 30 monitores que no andan en 15 funcionando a la perfecci=F3n)=

Garantia 6 MESES



From - Wed Apr 09 02:08:25 2003

Return-Path: <teem@horizontal.e-clk.com>

Received: from e-clk.com ([63.87.252.36])

by irresistable.cnchost.com

id DAA26528 for <rherardi@gssnet.com>; Wed, 9 Apr 2003 03:13:17 -0400 (EDT)

[ConcentricHost SMTP MX 1.31]

Date: Wed, 9 Apr 2003 03:13:17 -0400 (EDT)

Errors-To: <teem@horizontal.e-clk.com>

Message-ID: 20030408.206.422171628@e-clk.com

X-Mozilla-Status: 8001

X-Mozilla-Status2: 00000000

X-UIDL: 47151


I JUST WANTED TO MAKE SURE YOU RECEIVED

THIS e-mail.. VERY URGENT

X-UIDL: 47151



Here is the CORRECT link for you to click

on and take ADVANTAGE of our

MASSIVE ,MARKETING CAMPAIGN ASAP.........

http://www.e-clk.com/e/c.cgi?j=20030408_206&e=422171628&r=u33318&d=234&p=1

X-UIDL: 47151

We are a ROCK SOLID, 5 (FIVE) year old company $$




Thank you,

Priya.

Quote Reply
Re: [priyarak] extracting message blocks using perl In reply to
It looks more like an email than a log ;)

To parse it use MIME::Parser - you can find detailes at cpan.org
Quote Reply
Re: [Paul] extracting message blocks using perl In reply to
The log file consists of full headers and body of several email messages.

Will be able to extract message-id and body of the messages seperately using MIME::Parse?

I really appreciate your help. Smile

Thanks,

Priya
Quote Reply
Re: [priyarak] extracting message blocks using perl In reply to
Yes, MIME::Parser can read from a file handle or file and will parse the email fully.
Quote Reply
Re: [Paul] extracting message blocks using perl In reply to
I really appreciate your help. I am trying MIME::Parser now.

Thank you very much,

Priya.