I found an example IIS log file on Windows 2003 Server here . However, post your own lines in the sample log.
192.168.114.201, -, 03/20/01, 7:55:20, W3SVC2, SERVER, 172.21.13.45, 4502, 163, 3223, 200, 0, GET, /DeptLogo.gif, -,
Since this is nothing more than a separate comma-delimited file, you have several different ways to go here. You can use Text :: CSV if it is installed on your computer. If not, here is a simple example.
use strict;
use warnings;
use Data::Dumper;
my $user = {};
open $log, '<', 'path/to/logfile.log';
while (my $line = <$log>) {
my @fields = split /, /, $line;
push @{ $user->{$fields[1]} }, "$fields[12] $fields[13]";
}
close $log;
print Dumper $user;
This is the conclusion:
$VAR1 = {
'-' => [
'GET /DeptLogo.gif'
]
};
$user .
foreach my $u (sort keys %$user) {
print "$u\r\n";
foreach $action (@{ $user->{$u} }) {
print "$action\r\n";
}
}