@weekday = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
$weekday{$weekday[$_]} = $_ for (0..$#weekday);@month = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
$month{$month[$_]} = $_ for (0..$#month);
@mylog = (); # dummy
MAINLOOP:
while (<>) {
chomp;
next if /^\s*$/o;
if (/^\s*(\w\w\w) (\w\w\w) (\d+) (\d+):(\d+):(\d+) (\d+)/o &&
$weekday{$1} && $month{$2}) {
push @mylog, $cur_item if $cur_item;
$cur_item = [$weekday{$1}, $month{$2}, $3, $4, $5, $6, $7, '', 0];
next MAINLOOP;
}
if (/^\s*([\d\w-]+)\s*=\s*(.*)/o) {
($key, $val) = ($1, $2);
$val =~ s/\s+$//o;
$val = $1 if $val =~ /^"(.*)"$/o;
if ($key eq 'User-Name') {
$cur_item -> [7] = $val;
} elsif ($key eq 'Acct-Input-Octets') {
$cur_item -> [8] += $val;
} elsif ($key eq 'Acct-Output-Octets') {
$cur_item -> [8] += $val;
}
}
}
push @mylog, $cur_item if $cur_item;
print "$_->[7]\t$_->[8]b\t$weekday[$_->[0]] $month[$_->[1]] $_->[2] $_->[3]:$_->[4]:$_->[5] $_->[6]\n" for (@mylog);