Hello,
I writing a Perl script that would read a file and pick out the relevant information using Perl's RegEx.
The file I'm trying to read has this in it's contents:
==========================
==========
======
Message-ID: <1214683155.4866981375524@
webmail.fr
eedom.net>
Date: Sat, 28 Jun 2008 20:59:15 +0100
From: keith@f2s.com
To: kerry@hellow.com, kbde@singtel.com,
test@goodmail.com, test2@goodmail.com,
test3@goodmail.com, test4@goodmail.com
Subject: test 5
MIME-Version: 1.0
Content-Type: text/plain
==========================
==========
======
I'm trying to pick out the line/s where it begins with To: by using Perl's RegEx with no success. I'm a beginner with this language and would appreciate some guidance.
This is part of my script that reads this file using a while loop:
==========================
==========
=====
$gendir = "/home/vpopmail/domains/cu
r";
$gendest = "/home/vpopmail/domains/cu
r";
opendir (IN, "$gendir");
while ($f = readdir (IN) ){
next if $f eq '.';
next if $f eq '..';
open (FILE, "<$gendir/$f");
while (<FILE>) {
if (/^To:(.*,)/) {
$recip = $1;
print $recip;
}
if (/^Cc:(.*),/) {
$recip_two = $1;
}
if (/^Subject:(.*)/) {
$subject = $1;
}
if (/^From:(.*)/) {
$from = $1;
}
}
close FILE;
==========================
==========
=======
I'm successful with picking the first 2 email addresses in the To: ( kerry@hellow.com, kbde@singtel.com,) field but subsequent email addresses after that doesn't seem to work.
Can someone please assist?
Many Thanks
Start Free Trial