使用perl统计日志中单位时间内的请求数
2013-12-13 15:51
465 查看
$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"; } }
相关文章推荐
- AT收发短信
- 通过GWT RPC实现异步交互
- 进程与内存4-mmap实现1(nopage方法原理及实例)
- iOS开发:从新手到专家的一些建议
- Struts2学习笔记——初识项目结构
- distro packages dependency tree
- ftpUtil实现文件上传和下载
- 【九度】题目1511:从尾到头打印链表
- JAVA集集合类
- Histograms of Oriented Gradients for Human Detection
- web.xml配置详解 org.springframework.web.util.Log4jConfigListener
- springMVC+mybatis+dwr中如何使用dwr
- C#基础枚举的设计
- linux shell编程指南第二十章------向脚本传递参数
- Hard 计算0到n之间2的个数 @CareerCup
- JAVA基础之String类
- IOS调用相机,保存到沙盒
- COM(组件对象模型)简单介绍
- 指针应用
- WSDL 详解