Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: webserver common log format file script

by Marshall (Abbot)
on Sep 06, 2011 at 14:57 UTC ( #924418=note: print w/replies, xml ) Need Help??

in reply to webserver common log format file script

Your index values of @values, don't seem to match up with the standards for Common Log Format. You may be splitting on space instead of using a better regex. This parsing problem has already been solved. Ch 8, Parsing Web Access Logs of Perl for Web Site Management is from 2001, but lots is still relevant. There is a good explanation of the author's regex. This also explains how to search CPAN for modules that might be appropriate for your task.

In Perl, it is not necessary to write things like $values[ 6 ]. Instead, Perl has list slice. See slices in In other languages, you have to keep track of stuff like the "sixth thing" or index 6 means status, in Perl, just assign to a $status variable directly: ($status) = (split)[6]; This enhances readability.

Anyway, I would use some well known code or use a CPAN module to parse your log line. Then it would help if you explained a bit more about your troubles. You obviously seem to to understand the basics of regex. Where are you going wrong?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://924418]
and the pool shimmers...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2018-04-20 17:12 GMT
Find Nodes?
    Voting Booth?