I have a file that looks like this
[MsgName: XYZ status: Pass] [MsgName: ABC Status: Pass] [MSBN: BBB Status: Failed Error] [MSPAnamat: TTT Status: Pass] Now I have to read this file and create 2 log files Regular logs containing all data and other error logs, which only have errors in it
so in this case error log should only be shown
[MsgNa Me: bbb status: failed error
code> while ($ line [i ] = & Lt; FileHandle & gt; {Print ($ line [i] = ~ / ^ s * \] /) "RDID msg ->: / n $ line [i]; Next;} {Print out "$ line [i]"; if ($ line [i] = ~ / error /) {#### In this section I can not understand HD to get it my desired output print "error error For regular log output and error for printing I use out "[Error]
($ line [I] = / / p>
The easiest move is to store the file that you are interested in when You are tracing the file.
#! Use / usr / bin / perl strict; Use warnings; My @ fifo = ('') x 5; Start an empty array with # size = 5 (message block size) (file, "log.txt.txt"); While (& lt; FILE & gt;) {Push (@Figo, $ _); # Add element to end of ARM so that its size 6 changes @fifo; # Remove the first element in its size 5 if ($ FIFO [3] = ~ / error /) # Check that the fourth row of the block has an error {print @fifo; }} Close (FILE)
No comments:
Post a Comment