#!/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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |