I don't have time right now to address all of the specs of your project, but here's a start. This will, at least, demonstrate one way to match the text that you're trying to match in your posted code.
#!/usr/local/bin/perl -w use strict; #my $log = /path/to/your/log/file(s); #you will need to edit and uncomment the above line my @log_list; my $line; #open (LOG, "$log") || die "Can't open $log:$!\n"; #uncomment the above line, if you actually use this code :-) while ($line = <DATA>) { #change DATA to LOG or whatever filehandle you use, too! chomp $line; next unless ($line =~ /MAIL\s+FROM/); push (@log_list, $line); } #you will probably want to replace "next unless" with "if elsif" # in order to get the different matches that you require. foreach my $string(@log_list) { print "My string is $string\n"; #this print statement is simply to demonstrate the matching text. # obviously, you will define what YOU want to do with those matches. } __DATA__ Connection from 208.1.71.165, Mon Feb 12 08:54:01 2001 Connection from 208.1.71.165, Mon Feb 12 08:54:01 2001 Connection from 208.1.71.165, Mon Feb 12 08:54:01 2001 EHLO ancmail02.ancestry.com MAIL FROM:<Reminder@MyFamilyInc.com> MAIL FROM:<Reminder@MyFamilyInc.com> MAIL FROM:<Reminder@MyFamilyInc.com> RCPT TO:<user3@myhost.mydomain.net> RCPT TO:<user3@myhost.mydomain.net> DATA - 249 lines, 14229 bytes. DATA - 217 lines, 12388 bytes. DATA - 217 lines, 12403 bytes. __END__

In reply to Re: Parsing MercuryMail logs by Tuna
in thread Parsing MercuryMail logs by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.