View Single Post
  #9 (permalink)  
Old 04-20-05, 01:07 AM
kofcrazy kofcrazy is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Charlie, I got almost everything to work. I have two more things to ask. Can you explain this line of coding

my ($ip, $ts) = $header =~ /\[(.*)\]\).*>; (.*)$/;

because some of the email headers differs from the email header I posted. So I need to know how this line works and its syntax so I can modify it.
For example, it couldn't find the ip and date of this email:

Return-Path: <privateertuwl@boxfrog.com>
Delivered-To: em-ca-bait-excelled@em.ca
Received: (qmail 752 invoked from network); 31 Oct 2003 23:13:30 -0000
Received: from c-24-1-237-171.client.comcast.net (HELO boxfrog.com) (24.1.237.171)
by churchill.factcomp.com with SMTP; 31 Oct 2003 23:13:30 -0000
Received: from unknown (77.147.134.86)
by mail.gimmicc.net with esmtp; Sat, 01 Nov 2003 22:11:48 +0900
Received: from unknown (213.56.7.98)
by mail.webhostings4u.com with NNFMP; 02 Nov 2003 07:04:35 -0200
Received: from unknown (HELO smtp18.yenddx.com) (200.141.45.150)
by smtp4.cyberemailings.com with smtp; 02 Nov 2003 04:57:22 -0600
Message-ID: <9d3001c3a0c0$420cdc90$af916784@kdlxtqaaf>
Reply-To: <privateertuwl@boxfrog.com>
From: <privateertuwl@boxfrog.com>
To: "polemicmailcity" <bait-excelled@em.ca>
Subject: Lillian is a Cartoon looking for a master
Date: Sat, 01 Nov 2003 13:36:49 -0800


And when I run the code on the folder containing the emails, I get a lot of this:

Reading c:/2003/2003/10/1067645710.15548_35.txt... Done.
Reading c:/2003/2003/10/1067645711.15548_37.txt... Done.
Reading c:/2003/2003/10/1067645712.15548_40.txt... Done.


Oh I would like to extract only the last ip, or the first ip from bottom to top. In the case above it would be 200.141.45.150. Once I get this ip and the date that accompanies it, I would like to stop searching this email for any more ips. I was thinking to read starting from the end of the file and stop once it finds one ip. I'm not sure if this can be done.

Thanks
Sida
Reply With Quote