Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Extracts the IP addresses from the received headers of the messages and extract domains from the body of the messages



relroy
Novice

Apr 15, 2010, 8:05 PM


Views: 3541
Extracts the IP addresses from the received headers of the messages and extract domains from the body of the messages

I have a directory with 1000 files which contain email msgs .
Aim is to extract the IP addresses from the received headers of the messages and extract domains from the body of the messages to give output as below:-
File: filename2
IP: 12.2.3.40
Domain: domain2.com
Domain: domain3.com

Current code gives the filenames but isnt extracting IP address from the files, says uninitialized $_
-----------------------------------------------------------
#!C:/strawberry/perl/bin/perl
#directory.plx

use strict;
use warnings;

chdir("C:/Documents and Settings/Administrator/Directory101") or die "$!";
opendir (DIR, ".") or die "$!";
my @files = readdir DIR;
close DIR;

local @ARGV = @files;
foreach $ARGV (sort @ARGV)
{
print "Filename: $ARGV \n";
if (m /^d(,3)\.\d(1,3)\.\d(1,3)\.\d(1,3)\$/)
{
print "IP Address: $_ \n";
}
}


Any tips would be welcome. Thank you!


FishMonger
Veteran / Moderator

Apr 16, 2010, 6:08 AM


Views: 3531
Re: [relroy] Extracts the IP addresses from the received headers of the messages and extract domains from the body of the messages

For those who may post a response, this is a homework assignment which is already being worked on.

http://perlguru.com/gforum.cgi?post=45826


relroy
Novice

Apr 16, 2010, 6:34 AM


Views: 3528
Re: [FishMonger] Extracts the IP addresses from the received headers of the messages and extract domains from the body of the messages

--- Thread closed ---