Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Parsing a log file

by Anonymous Monk
on Jul 13, 2000 at 05:07 UTC ( [id://22307]=note: print w/replies, xml ) Need Help??


in reply to Parsing a log file

Don't ignore the header lines. They tell you the order of the fields, which can change whenever someone reconfigures IIS to emit different information into the logs. Try something along these lines:
my @fields = ();
my %fields = ();

while ( <LOG> ) {
    chomp;
    if ( m/^#/ ) {
        if ( s/^#Fields: // ) {
            @fields = split(/ /, $_);
        }
        next;
    }

    @fields{@fields} = split(/ /, $_);

    my $uri = $fields{'cs-uri-stem'};

    # The rest is left as an exercise

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://22307]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2025-04-30 22:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.