Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#Software: Microsoft Internet Information Server 4.0
#Version: 1.0
#Date: 2000-06-28 00:00:29
#Fields: time c-ip cs-method cs-uri-stem sc-status
00:00:29 192.168.20.50 GET /Plastic/ProductTop.html 200
00:00:29 192.168.20.50 GET /Plastic/images/ProductNavTopRt.jpg 304
00:00:29 192.168.20.50 GET /plastic/ProductNav.html 200
00:00:29 192.168.20.50 GET /plastic/images/ProductNav1b.jpg 304
00:00:29 192.168.20.50 GET /main.html 202
I understand how to open files and read individual lines from the file, and how to format the output, but I'm stuck on the parsing of individual sections of the line.
What I specifically am interested in is counting up every file type (eg- .gif, .html, .jpg) AND the times each file type has a unique code (eg- 304, 200, 202). So for the above snippet the output would look something like:
| File type | Code | Occurences |
|---|---|---|
| .jpg | 304 | 2 |
| .html | 200 | 2 |
| .html | 202 | 1 |
Of course, I would need to ignore any lines that did not have these codes (eg- the header lines). I've considered that using an array might be the best solution, but am lost on the algorithm necessary to achieve this.
Thanks for any help or ideas in the right direction.
-bri-
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing a log file
by Ovid (Cardinal) on Jul 13, 2000 at 00:06 UTC | |
|
Re: Parsing a log file
by nuance (Hermit) on Jul 13, 2000 at 00:19 UTC | |
|
Re: Parsing a log file
by le (Friar) on Jul 13, 2000 at 00:07 UTC | |
|
Re: Parsing a log file
by ahunter (Monk) on Jul 13, 2000 at 00:16 UTC | |
|
Re: Parsing a log file
by Anonymous Monk on Jul 13, 2000 at 05:07 UTC | |
|
RE: Parsing a log file
by CMonster (Scribe) on Jul 13, 2000 at 02:24 UTC | |
|
RE: Parsing a log file (analog, webalizer)
by ybiC (Prior) on Jul 13, 2000 at 00:29 UTC | |
|
Re: Parsing a log file
by Maclir (Curate) on Jul 13, 2000 at 02:09 UTC |