如果时间戳匹配,我正在努力寻找一种将下一行附加到当前行的方法。到目前为止,这是我的代码:
open(FH, "error_log:);
@data = <FH>
foreach $line (@data) {
if ( ($line =~ /notice/)) {
$line =~ s/ /,/g;
my @L1 = split(/|notice|\[|\]|,mpmstats:,|\t|rdy,|bsy,
+|rd,|wr,|ka,|log,|dns,|cls,|bsy:,|in,|/, $line);
$line =~ s/|notice|\[|\]|,mpmstats:,|\t|rdy,|bsy,|rd,|
+wr,|ka,|log,|dns,|cls,|bsy:,|in,//g;
print $line;
请注意,我打印只是为了查看输出。输出如下:
Wed,Jun,13,10:40:35,2012,758,42,0,29,11,0,0,2
Wed,Jun,13,10:40:35,2012,29,mod_was_ap22_http.c
Wed,Jun,13,10:41:35,2012,761,39,0,34,5,0,0,0
Wed,Jun,13,10:41:35,2012,34,mod_was_ap22_http.c
Wed,Jun,13,10:42:35,2012,769,31,0,22,6,0,0,3
Wed,Jun,13,10:42:35,2012,22,mod_was_ap22_http.c
Wed,Jun,13,10:43:35,2012,754,46,0,29,17,0,0,0
我希望将数字(第 2 行的 29)以 csv 形式放置在与时间戳对应的第一行的其他数字之后。可以删除该行的其余部分。如果该行下面没有任何内容(例如最后一行),我想附加一个零。感谢您的帮助。
这是所要求的输入数据的一部分:
[Wed Jun 13 01:41:24 2012 [error [client 10.119.84.9 File does not exist: /ebiz/b2b/IHS70prd/htdocs/offline.b2bonline.html
[Wed Jun 13 01:41:25 2012 [error [client 10.119.84.9 File does not exist: /ebiz/b2b/IHS70prd/htdocs/offline.b2bonline.html
[Wed Jun 13 01:41:25 2012 [error [client 10.119.84.8 File does not exist: /ebiz/b2b/IHS70prd/htdocs/offline.b2bonline.html
[Wed Jun 13 01:41:28 2012 [error [client 10.119.116.8 File does not exist: /ebiz/b2b/IHS70prd/htdocs/offline.b2bonline.html
[Wed Jun 13 01:41:28 2012 [error [client 10.119.84.8 File does not exist: /ebiz/b2b/IHS70prd/htdocs/offline.b2bonline.html
[Wed Jun 13 01:41:34 2012 [notice mpmstats: rdy 786 bsy 14 rd 0 wr 11 ka 3 log 0 dns 0 cls 0
[Wed Jun 13 01:41:34 2012 [notice mpmstats: bsy: 11 in mod_was_ap22_http.c
[Wed Jun 13 01:41:34 2012 [error [client 10.119.84.9 File does not exist: /ebiz/b2b/IHS70prd/htdocs/offline.b2bonline.html
[Wed Jun 13 01:41:35 2012 [error [client 10.119.84.9 File does not exist: /ebiz/b2b/IHS70prd/htdocs/offline.b2bonline.html