Hello Monks
I really did not want to ask this but i am really stuck and have no way out so desperately in need of some guidance. I'm trying to create a script that read a large file of sendmail log, store it in $HoAoA and grep the email address entered from prompt and return all the entries related to that email based on the $id. This is what i have now.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper; <
my %HoAoA;
while ( <DATA> ) {
my @fields = split(/
:,\s+/, $_, 4);
push @{ $HoAoA{$fields
1} }, [ @fields
0,2,3 ];
}
my @addresses;
foreach my $id ( keys %HoAoA ) {
if ( grep(/econgame\@worldgameofeconomics.com/, $HoAoA{$id}->[0]
1, $HoAoA{$id}->
11) ) {
push @addresses, $HoAoA{$id}->[0]
1, $HoAoA{$id}->
11;
}
}
__DATA__
Dec 8 08:49:21 b.mx.sonic.net sm-mta
18242: jB8GnCuK018242: from=<cj@oreilly.com>, size=10731, class="0", nrcpts=2, msgid=<E4461FEB-1B74-4612-80DC-3A39B04D89B1@oreilly.com>, proto=ESMTP, daemon=MTA, relay=mwest.oreilly.com
209.204.146.24
Dec 8 08:49:21 b.mx.sonic.net sm-mta
17961: jB8Gn2v5017961: lost input channel from 200216009099.user.veloxzone.com.br
200.216.9.99 to MTA after rcpt
Dec 8 08:49:21 b.mx.sonic.net sm-mta
17961: jB8Gn2v5017961: from=<je-hurn@mamma.com>, size=0, class="0", nrcpts=0, proto=SMTP, daemon=MTA, relay=200216009099.user.veloxzone.com.br
200.216.9.99
Dec 8 08:49:21 d.mx.sonic.net sm-mta
6438: jB8Gn1iU006438: Milter: to=<econgame@worldgameofeconomics.com>, reject=550 5.7.1 Recipient declines mail from 221.233.54.253, (DUL), see http://www.mail-abuse.com/cgi-bin/lookup?ip_address=22
1.233.54.253
Dec 8 08:49:21 c.mx.sonic.net sm-mta
30845: jB8GgMPb030845: from=<Michael@MichaelRomano.net>, size=2786810, class="0", nrcpts=0, proto=ESMTP, daemon=MTA, relay=b.mail.sonic.net
64.142.19.5
Dec 8 08:49:21 b.mx.sonic.net sm-mta
18528: jB8GnCuK018242: to=<mkirk@corp.sonic.net>,<dane@corp.sonic.net>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=160731, relay=lds.sonic.net.
208.201.249.231, dsn=2.0.0, stat=Sent (jB8GnLpC004736 Message accepted for delivery)
Dec 8 08:49:21 a.mx.sonic.net sm-mta
3699: jB8Gn9Vt003699: Milter: to=<cvd@sonic.net>, reject=550 5.7.1 Recipient declines email from 80.54.242.112, <spamhaus-xbl>, Ref: http://www.spamhaus.org/query/bl?ip=80.54.242.112
Dec 8 08:49:21 a.mx.sonic.net sm-mta
3699: jB8Gn9Vt003699: lost input channel from host2-112.btk.net.pl
80.54.242.112 to MTA after rcpt
Dec 8 08:49:21 a.mx.sonic.net sm-mta
3699: jB8Gn9Vt003699: from=<qfqsoftmtja@hotmail.com>, size=0, class="0", nrcpts=0, proto=SMTP, daemon=MTA, relay=host2-112.btk.net.pl
80.54.242.112
It works for some emails such as cj@oreilly.com but not for all. I really don't understand why. Please help. Thank you all.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.