With the help of hash, this is what I used:
use Data::Dumper;
open(FH,'inlog.txt');
my %stat;
my ($exitstatus, $exitstatusval, $exittime, $exittimeval, $exitcommands);
while ($line = <FH>) {
if ($line =~ m/^(\d+)\s+.*@(.*)/) {
$exitcommands = $2;
$qbsid= $1;
}
if ($line =~ /Exit Status/) {
($exitstatus, $exitstatusval) = split(':',$line);
next;
}
if ($line =~ /Exit time/ and $exitstatusval == 2) {
($exittime, $exittimeval) = split(': ',$line);
$stat{$qbsid} = {
commands => $exitcommands,
time => $exittimeval
};
}
}
print(Dumper(\%stat));