My first suggestion would be to see if there is anything on CPAN that could handle the log entries in a way that would be of use to you. A quick search suggested things like Apache::Logmonster and Apache::ParseLog (among others), and you could look at the source of other modules to see how they may have done it.
A while back, I looked at this kind of thing for my own curiousity. Looking at the code I was playing with, this might be of some usefulness to you:
# usual strict and warnings and such use Date::Parse; # to parse the entry date use Text::ParseWords; # to handled quoted entries # $logfile defined in skipped code open DF, $logfile or die $!; while (<DF>) { chomp; # the following conversion is so the date can be # captured intact s/(\[|\])/"/g; my @part = Text::ParseWords::quotewords( '\s+', 0, $_ ); $part[3] = str2time( $part[3] ); # deal with whatever part # of the log entry here you need } close DF;
Hope that helps.
In reply to Re: Parsing Apache logs with Regex
by atcroft
in thread Parsing Apache logs with Regex
by TheGorf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |