perl 跨行匹配文件内容 双层过滤
来源:互联网 发布:知豆电动汽车汽车之家 编辑:程序博客网 时间:2024/05/20 21:19
日志特点:分段,格式固定;取出所需数字 按格式写到另外的文件
需要用perl实现将made和lose的数据如数到result.txt文件中,结果数据格式如下:Teacher:6 4 6 4 6 4Student:6 4 6 4 6 4数字之间用tab间隔#!/bin/perl -wuse strict;my ($a, $b, $c);open my $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;open my $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:10 made:6Ball number:10 :attempt:10 lose:4pass succeedWe will test Group1...Teacher begin first -name B:applaud number 100:not applaud number 100Ball number:10 :attempt:10 made:6Ball number:10 :attempt:10 lose:4pass succeedWe will test Group1...Teacher begin first -name C:applaud number 100:not applaud number 100Ball number:10 :attempt:10 made:6Ball number:10 :attempt:10 lose:4pass succeedWe will test Group1...Student begin first -name A:applaud number 100:not applaud number 100Ball number:10 :attempt:10 made:6Ball number:10 :attempt:10 lose:4pass succeedWe will test Group1...Student begin first -name B:applaud number 100:not applaud number 100Ball number:10 :attempt:10 made:6Ball number:10 :attempt:10 lose:4pass succeed=cut
- perl 跨行匹配文件内容 双层过滤
- perl 跨行匹配;
- perl 修改文件内容
- perl读取文件内容
- perl 文件内容替换
- perl glob 过滤文件列表
- 内容过滤中关键字的匹配函数
- 文件内容匹配
- 两个文件内容匹配
- perl删除文件一行内容
- linux perl 批量替换文件内容
- perl命令行批量修改文件内容
- 文件内容替换 :SED 命令 和 Perl
- 使用 Perl 脚本做文件内容替换
- perl命令批量替换文件内容
- [perl] 一句命令进行跨行匹配替换
- 文件查找和内容过滤命令
- shell递归实文件内容过滤
- hostapd
- 通过WEBDAV管理Domino中的文件资源
- refresh a page
- JavaScript编程宝典
- Flex特效的一个小示例(state、呈示器、mxml外观用法)
- perl 跨行匹配文件内容 双层过滤
- 函数库文件
- eclipse 中的注释 快捷键
- session_unset and session_destroy
- 读书笔记:交互设计精髓
- .net 使用ajax控件后如何调用前端脚本
- Android应用换肤
- 随机取样和洗牌算法
- buffer control