perl统计各组游戏服务器同一个任务每个角色完成次数,次数异常封号处理
#!/usr/bin/perl
use strict;
my $log = 'task_accomplished.bz2';
my $result = 'result.txt';
my %count;
unlink $result if(-f $result);
open(LOG,"bzcat $log|");
open(RT,">>$result");
while(my $line = <LOG>)
{
chomp($line);
if($line =~ /srbgn=(\d+).*task_accomplished:roleid=(\d+)/)
{
my($sid,$roleid) = ($1,$2);
if(not $count{$sid}{$roleid})
{
$count{$sid}{$roleid} = 1;
}else
{
$count{$sid}{$roleid} += 1;
}
}
}
close(LOG);
foreach my $k (keys %count)
{
print "#### $k\t roleid \t count\n";
print RT "#### $k\t roleid \t count\n";
foreach my $k1 (keys %{$count{$k}})
{
if($count{$k}{$k1} > 1)
{
print "\t\t$k1\t$count{$k}{$k1}\n";
print RT "\t\t$k1\t$count{$k}{$k1}\n";
}
}
}
close(RT);
运行结果:
.....