取出文本的内容赋值给变量
时间:2010-09-29
来源:互联网
文件名:freemoney.log
Table RP.ALL_AREAACCOUNT_BAL_TEST:
108405 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 1548000 bytes(1000 rows)
Read buffer bytes: 5120000
Total logical records skipped: 0
Total logical records read: 108405
Total logical records rejected: 0
Total logical records discarded: 0
Run began on Tue Sep 28 18:40:19 2010
Run ended on Tue Sep 28 18:40:29 2010
这么一段,如何取出
RP.ALL_AREAACCOUNT_BAL_TEST,108405,Tue Sep 28 18:40:19 2010,Tue Sep 28 18:40:29 2010
这些信息,然后放在变量
$table='RP.ALL_AREAACCOUNT_BAL_TEST';
$rows=108405;
$timefirst='Tue Sep 28 18:40:19 2010';
$timeend='Tue Sep 28 18:40:29 2010';
Table RP.ALL_AREAACCOUNT_BAL_TEST:
108405 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 1548000 bytes(1000 rows)
Read buffer bytes: 5120000
Total logical records skipped: 0
Total logical records read: 108405
Total logical records rejected: 0
Total logical records discarded: 0
Run began on Tue Sep 28 18:40:19 2010
Run ended on Tue Sep 28 18:40:29 2010
这么一段,如何取出
RP.ALL_AREAACCOUNT_BAL_TEST,108405,Tue Sep 28 18:40:19 2010,Tue Sep 28 18:40:29 2010
这些信息,然后放在变量
$table='RP.ALL_AREAACCOUNT_BAL_TEST';
$rows=108405;
$timefirst='Tue Sep 28 18:40:19 2010';
$timeend='Tue Sep 28 18:40:29 2010';
作者: leoxqing 发布时间: 2010-09-29
文件中这种结构只有一个还是重复出现啊
作者: 珞水的大叔 发布时间: 2010-09-29
回复 珞水的大叔
不是重复出现的!
不是重复出现的!
作者: leoxqing 发布时间: 2010-09-29
回复 leoxqing
复制代码
- while(<DATA>){
- if(/^Table\s(.*):$/){
- $table = $1;
- next;
- }
- if(/^\s+(\d+)\s+Rows successfully loaded\.$/){
- $rows = $1;
- next;
- }
- if(/^Run began on\s+(.*)$/){
- $timefirst = $1;
- next;
- }
- if(/^Run ended on\s+(.*)$/){
- $timeend = $1;
- next;
- }
- }
作者: 珞水的大叔 发布时间: 2010-09-29
#!/usr/bin/perl
use strict;
use warnings;
undef $/;
my $data = <DATA>;
$data =~ /table\s*(.*?):/i;
my ($table,$rows,$timefirst,$timeend) = ($data =~ /table\s*(.*?):.*?(\d+)\s*Rows.*?began on\s*(.*?)\n.*?ended on\s*(.*?)\n$/is);
print "Table: $table\nRows: $rows\nTimefirst: $timefirst\nTimeend: $timeend\n";
<STDIN>;
__DATA__
Table RP.ALL_AREAACCOUNT_BAL_TEST:
108405 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 1548000 bytes(1000 rows)
Read buffer bytes: 5120000
Total logical records skipped: 0
Total logical records read: 108405
Total logical records rejected: 0
Total logical records discarded: 0
Run began on Tue Sep 28 18:40:19 2010
Run ended on Tue Sep 28 18:40:29 2010
use strict;
use warnings;
undef $/;
my $data = <DATA>;
$data =~ /table\s*(.*?):/i;
my ($table,$rows,$timefirst,$timeend) = ($data =~ /table\s*(.*?):.*?(\d+)\s*Rows.*?began on\s*(.*?)\n.*?ended on\s*(.*?)\n$/is);
print "Table: $table\nRows: $rows\nTimefirst: $timefirst\nTimeend: $timeend\n";
<STDIN>;
__DATA__
Table RP.ALL_AREAACCOUNT_BAL_TEST:
108405 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 1548000 bytes(1000 rows)
Read buffer bytes: 5120000
Total logical records skipped: 0
Total logical records read: 108405
Total logical records rejected: 0
Total logical records discarded: 0
Run began on Tue Sep 28 18:40:19 2010
Run ended on Tue Sep 28 18:40:29 2010
作者: iamlimeng 发布时间: 2010-09-29
楼上V5!
作者: leoxqing 发布时间: 2010-09-29
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28