#!/usr/local/bin/perl -w # #---------------------------------------------------------------# # A program to read an Apache access_log file in ECLF format. # #---------------------------------------------------------------# $logFile = "access_log"; open (LOGFILE,"$logFile") || die " Error opening log file $logFile.\n"; while() { chomp; #----------------------------------------------# # condense one or more whitespace character # # to one single space # #----------------------------------------------# s/\s+/ /go; #----------------------------------------------------------# # the next line breaks each line of the access_log into # # nine variables # #----------------------------------------------------------# ($clientAddress, $rfc1413, $username, $localTime, $httpRequest, $statusCode, $bytesSentToClient, $referer, $clientSoftware) = /^(\S+) (\S+) (\S+) \[(.+)\] \"(.+)\" (\S+) (\S+) \"(.*)\" \"(.*)\"/o; #----------------------------# # put your logic here ... # #----------------------------# } close (LOGFILE);