![]() |
|
Problems? Is your data what you think it is? | |
PerlMonks |
Re: Parsing a log fileby Anonymous Monk |
on Jul 13, 2000 at 05:07 UTC ( [id://22307]=note: print w/replies, xml ) | Need Help?? |
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
In Section
Seekers of Perl Wisdom
|
|