I have a log file which looks like below:
874899 root@commands to execute some files
Exit Status : 0
Exit time : Sun May 5 18:19:39 2013
874923 root@commands to execute some files
Exit Status : 2
Exit time : Sun May 5 18:19:42 2013
I have a script which looks at a pattern and returns the below line of that matched pattern. The script is as follows:
open(FH,'log.txt');
while ($line = <FH>) {
if ($line =~ /Exit Status/) {
print "$line";
print scalar <FH>;
}
}
I need your input regarding how should I do this, such that it matches the Exit status
(as 2 in this case) and save the 874923
line along with the commands (In this case) and the Exit Time
as two separate variables.
Please correct me as I am a newbie in perl.