[Wellington-pm] Today's tricky perl teaser
Cliff Pratt
enkidu at cliffp.com
Mon Nov 27 22:23:40 PST 2006
I now know why, but can anyone spot why the regex will not compile on
the date/time line? (Please ignore the inappropriate line breaks).
Cheers,
Cliff
open LOGS, "/usr/apache2/logs/vr2-wg-prod-http-01.access.log" or
die "Can't open logfile : $!" ;
while (<LOGS>) {
@fields = /(^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) # Host
IP address
\s+(.+?) # Remote logname
\s+(.+?) # Remote user
\s+(\[.*\]) # Date / time
\s+(\".+?\") # Request (first line)
\s+(\d{3}) # Last status code
\s+(\d+|-) # Bytes transferred
\s+(\".*?\") # Referrer (from request
header)
\s+(\".*?\") # User-Agent (from
request header)
\s+(.+)$/x ; # Host (from request
header)
#
if ($fields[5] eq '403') {
print "$fields[0], $fields[2], refused
connection\n" ;
}
}
close LOGS ;
More information about the Wellington-pm
mailing list