日志特点:分段,格式固定;取出所需数字 按格式写到另外的文件

需要用perl实现将made和lose的数据如数到result.txt文件中,结果数据格式如下: Teacher: 6 4 6 4 6 4 Student: 6 4 6 4 6 4 数字之间用tab间隔
#!/bin/perl -wusestrict;my($a,$b,$c);openmy$data,"< data.txt"or die$!;while(<$data>) {if(/^Teacher/sbegin/sfirst/../^pass/ssucceed/){if(/^Ball/){chomp($a=(split':',$_)[4]);$b.=$a."/t";}}if(/^Student/sbegin/sfirst/../^pass/ssucceed/){if(/^Ball/){chomp($a=(split':',$_)[4]);$c.=$a."/t";}} }close$data;openmy$fh,">result.txt";print$fh"Teacher:/n"; print$fh$b."/n";print$fh"Student:/n"; print$fh$c."/n";close$fh;=head__DATA__We will test Group1...Teacher begin first -name A:applaud number 100:not applaud number 100Ball number:10:attempt:10made:6Ball number:10:attempt:10lose:4pass succeed We will test Group1...Teacher begin first -name B:applaud number 100:not applaud number 100Ball number:10:attempt:10made:6Ball number:10:attempt:10lose:4pass succeed We will test Group1...Teacher begin first -name C:applaud number 100:not applaud number 100Ball number:10:attempt:10made:6Ball number:10:attempt:10lose:4pass succeed We will test Group1...Student begin first -name A:applaud number 100:not applaud number 100Ball number:10:attempt:10made:6Ball number:10:attempt:10lose:4pass succeed We will test Group1...Student begin first -name B:applaud number 100:not applaud number 100Ball number:10:attempt:10made:6Ball number:10:attempt:10lose:4pass succeed=cut

perl 跨行匹配文件内容 双层过滤相关推荐

  1. linux find查找多个关键字,Linux小技巧:find . | xargs grep -ri 关键字 -l —— 查询、匹配文件内容关键词...

    大家在工作中,是否遇到需要查询某个文件下内容中的关键词是否存在.例如: 需要查询在/etc/passwd下是否存在"yasuo"关键字: [[email protected] ~] ...

  2. 学习笔记:内容安全过滤技术

    #内容安全过滤技术 总体介绍 文件内容过滤 文件过滤流程 内容过滤 过滤类型 关键字 内容过滤处理流程 邮件过滤 邮件协议介绍 RBL黑名单的查询 邮件内容过滤 应用行为控制技术 总体介绍 文件过滤技 ...

  3. 文件内容替换 :SED 命令 和 Perl

    Linux文件内容替换 Perl  把文件file.txt中的before改为after perl -pi -e  's/before/after/g'  file.txt -p 表示匹配文件的每一行 ...

  4. 过滤文件内容(windows和Mac及ubuntu)

    windows系统 可以使用TextFilter软件 linux系统(包含mac) grep "过滤内容" 要过滤的文件 如:grep "BasePage___" ...

  5. linux 上使用wc -l命令快速查看文件内容有多少行,以及如何匹配指定字符查看多少行

    1 linux的cat -n命令查看文件内容一共有多少行 1.cat -n命令查看文件多少行 cat -n filename 如:cat -n gallery_color_depth.txt - 2. ...

  6. 正则匹配html标签和内容,正则匹配HTML标签(不保留内容和保留内容、过滤标签的的属性)...

    1.匹配双标签(包括内容),过滤标签,不保留内容. var reg1 = /]*>(.|\n)*/gi; var str1 = '我是被删除的123123'; console.log(str1. ...

  7. python将两个excel匹配_Python3实现两个Excel文件内容比对

    #-*- coding: utf-8 -*- #比对两个Excel文件内容的差异 #---------------------假设条件---------------- #1.源表和目标表格式一致 #2 ...

  8. perl 文件内容替换

    命令: perl 命令可以批量替换文件中的一些内容,操作起来非常高效.下面举几个例子: perl -pi -e "s/aaa/bbb/gi" test.txt 上面的命令把test ...

  9. PHP获取随机数据,匹配出内容,存文件

    一.流程 二.代码 三.文件内容 一.流程 1.getRandData()随机方法返回一条html数据 2.匹配出数据中的内容 3.判断文件是否存在 3.1.存在,则判断数据是否已存入文件 3.11. ...

最新文章

  1. 比如“古今数学思想”,BBC的“数学的故事”视频,一起看效果会更好
  2. Help Jimmy(递归)
  3. .. 相对目录php,php 计算两个目录的相对路径
  4. python四大数据类型_Python 四大数据类型总结
  5. SpringTest2
  6. 【详细解析】1080 MOOC期终成绩 (25分)_45行代码AC
  7. 八年溯源,如何巧搭区块链
  8. StackExchange.Redis 使用 (一)
  9. Oracle 数据怎么实时同步到 MySQL | 亲测干货分享建议收藏
  10. html水滴掉下来越来越来越淡代码,水滴落到水面就消失了?没那么简单!看水滴如何翩翩起舞!...
  11. java序列化与反序列化总结
  12. 手机发包工具_【发包工具】http多线程发包工具
  13. 《经济地理学》读书笔记
  14. android 设备唯一码的获取,Cpu号,Mac地址
  15. Apache Flink 学习教程----持续更新
  16. python是一种解释型、面向什么的计算机程序设计语言_Python \解释型计算机程序设计语言...
  17. java考勤表导出_Sql通过存储过程生成全年日历考勤表数据
  18. 基于BRNN的政务APP评论端到端方面级情感分析方法
  19. Oracle 自定义数据类型Type
  20. Exception in Thread: ValueError: signal number 32 out of range

热门文章

  1. myeclipse怎么集成Tomcat
  2. [APP] Android 开发笔记 001-环境搭建与命令行创建项目
  3. springMVC配置文件spring-servlet.xml中mvc:annotation-driven /的意义
  4. 不能在DropDownList 中选择多个项
  5. Chrome OS 0.4.220 Beta下载已发布
  6. [Pyhon疫情大数据分析] 三.新闻信息抓取及词云可视化、文本聚类和LDA主题模型文本挖掘
  7. 【数据结构与算法】之深入解析图的拓扑排序
  8. 中国大学MOOC 计算机组成原理第4章 测试(中)
  9. 2018年第九届蓝桥杯C/C++ C组国赛 —— 第四题:约瑟夫环
  10. 2017第八届蓝桥杯C/C++ B组省赛 —— 第一题:购物单