タイムスタンプが一致する場合、現在の行に次の行を追加する方法を見つけるのに苦労しています。これまでの私のコードは次のとおりです。
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