Update for new logfile format

This commit is contained in:
dcp1990 2005-06-01 00:13:20 +00:00
parent f55f73e2a9
commit 9ac5e887be

View file

@ -1,23 +1,20 @@
#!/usr/bin/perl #!/usr/bin/perl
# Parses a log and generates some useless statistics. # Parses a log and generates some useless statistics.
# $Amigan: cidserv/parselog.pl,v 1.1 2004/12/23 23:46:01 dcp1990 Exp $ # $Amigan: cidserv/parselog.pl,v 1.2 2005/06/01 00:13:20 dcp1990 Exp $
# (C)2004 Dan Ponte. BSD. # (C)2004 Dan Ponte. BSD.
$logfile = $ARGV[0]; $logfile = $ARGV[0];
%stat = ('me' => (phone => '123345', times => 1,),); #%stat = ('me' => (phone => '123345', times => 1,),);
%numstat = (123345 => \$stat{'me'}); #%numstat = (123345 => \$stat{'me'});
open(LF, $logfile); open(LF, $logfile);
@cont = <LF>; print "parselog.pl v2.\n";
close(LF); foreach(<LF>) {
print "parselog.pl v1.\n"; if($_ =~ /^..:..:..: L[0-9]{2}\/[0-9]{2} (....):(....):(.+):(.+)$/) {
foreach(@cont) { my ($dat, $tim, $nam, $phn) = ($1, $2, $3, $4);
if($_ =~ /^Phone Number: ([0-9]+)$/) { $stat{$nam}{'name'} = $nam;
$stat{$lnam}{'phone'} = $1; $stat{$nam}{'phone'} = $phn;
$numstat{$1} = \$stat{$lnam}; $numstat{$phn} = \$stat{$nam};
} elsif ($_ =~ /^Name: (.+)$/) { $stat{$nam}{'times'}++;
$stat{$1}{'times'}++;
$tottimes++; $tottimes++;
$stat{$1}{'name'} = $1;
$lnam = $1;
} }
} }
while(($k, $v) = each(%stat)) { while(($k, $v) = each(%stat)) {
@ -29,4 +26,5 @@ while(($k, $v) = each(%stat)) {
} }
#print "be " . ${${$numstat{$hn}}}{'times'} . "\n"; #print "be " . ${${$numstat{$hn}}}{'times'} . "\n";
print ${${$numstat{$hn}}}{'name'} . " ($hn) called the most times, at $lg.\n"; print ${${$numstat{$hn}}}{'name'} . " ($hn) called the most times, at $lg.\n";
print "In total, people called here $tottimes times.\n"; print "In tottal, people called here $tottimes times.\n";
close(LF)