我有一個文件看起來像這樣如何解析和檢測perl中日誌文件中的一行代碼塊?
[
MsgName:XYZ
Status:Pass
]
[
MsgName:ABC
Status:Pass
]
[
MsgName:bbb
Status:Fail
Error
]
[
MsgName:ttt
Status:Pass
]
現在我想在這
讀取該文件,並創建2個日誌文件 包含所有數據,並含有唯一的錯誤數據的其他錯誤日誌中一個常規LOG所以在這種情況下,錯誤日誌應該只顯示
[
MsgName:bbb
Status:Fail
Error
]
和regfular記錄所有
任何人都可以指導我如何做到這一點
我試過這樣
while($line[i]=<FileHandle>
{
if($line[i]=~ /^s*\]/)
{
print OUT "recd new msg-->:/n $line[i];
next;
}
do
{
print OUT "$line[i]";
if($line[i]=~ /Error/)
{ ####this section i cannot figure out hw to frame it get my desired output
print "error found
print ERROROUT .....
} until($line[i]=~ /^s\]
這裏我用OUT的常規日誌輸出 和ERROROUT錯誤日誌
我想補充我希望錯誤味精的整個塊,而不僅僅是錯誤行 – user2486369