You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Saurabh Goyal <Sa...@citysearch.com> on 2000/07/29 01:20:50 UTC

Parsing the Transfer Log

> Hi,
> 
> I am trying to parse the apache transfer log (access_log) record and
> getting the error, I am doing the following, but it's not working. Any one
> have idea, why it's not working?
> 
> ######### Test Code Begin ##########
> use strict;
> 
> $_ = "10.0.48.146 - - [28/Jul/2000:13:22:37 -0700] \"GET /home/test.html
> HTTP/1.0\" 200 193";
> 
> if(/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+) "(\S+) (.*?)
> (\S+)" (\S+) (\S+)$/)
> {
> 	print "Client   : $1\n";
> 	print "IdentUser: $2\n";
> 	print "AuthUser : $3\n";
> 	print "Date     : $4\n";
> 	print "Time     : $5\n";
> 	print "TimeZone : $6\n";
> 	print "Method   : $7\n";
> 	print "URL      : $8\n";
> 	print "Protocol : $9\n";
> 	print "Status   : $10\n";
> 	print "Bytes    : $11\n";
> }
> ########## Test Code End ##########
> 
> Thanks,
> Saurabh
> 
> 

Re: Parsing the Transfer Log

Posted by re...@ch.twi.tudelft.nl.
On Fri, 28 Jul 2000, Saurabh Goyal wrote:

> > Hi,

> > $_ = "10.0.48.146 - - [28/Jul/2000:13:22:37 -0700] \"GET /home/test.html
                                                     ^
> > HTTP/1.0\" 200 193";

> > if(/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+) "(\S+) (.*?)
                                                           ^
add:

  \]

you do not match the ending ], since you match everything until ], but you
forgot the ] itself...

> > (\S+)" (\S+) (\S+)$/)

bye,
remco

/----------------------------------------------------------------------\
| Remco Schaar                                                         |
| e-mail: Remco@ch.twi.tudelft.nl                                      |
\----------------------------------------------------------------------/

    South Park meets Linux:
        - "Oh my God, they killed init!"
        - "You bastards!"