$file="g:/log/x.log";
%map=();
open(IN,"<$file") || die "Couldn't open $filename for reading: $!";
$num=0;
$v=0;
$str="";
while($line=<IN>)
{
if (!($line=~m/.*logid.*phonenumber.*message.*/)) {#不匹配就继续循环
next;
}
#print $line."\n";
$str=substr($line,0,20);#cut str
if(exists ($map{$str}))
{
$v=$map{$str};
$v++;
$map{$str}=$v;
}else{
$map{$str}=1;
}
#print $str."===".$map{$str}."\n";
}
close($IN);
while (($key, $value) = each(%map) ) {
if($value>40){
print "$key ------$value "."\n";
}
}
使用perl统计日志中单位时间内的请求数
最新推荐文章于 2024-08-23 00:23:02 发布