Ok try
#!/usr/bin/perl
use strict;
my $reqid = '8274';
my $infile = 'worker.log';
open IN,'<',$infile or die "$!";
# input
my %data = ();
my @id = ();
while (<IN>) {
chomp;
next unless /Task:id=(\d+)/;
my $taskid = $1;
my (undef,$timestamp,undef) = split /\s+/,$_,3;
if (/(Started|Submitted|Done).*(consuming|job)/){
my $i = ($1 eq 'Done') ? 1 : 0;
my $proc = ($2 eq 'consuming') ? $2 : 'Submitted';
$data{$taskid}{$proc}[$i] = $timestamp;
}
while ( /\{(\d+)-SUCCESSFUL\}/g ){
push @id,$1 if ($taskid eq $reqid);
}
}
close IN;
# output
print join ',',('Task id','Start time',"End time\n");
for my $id (sort @id){
if (exists $data{$id}){
for my $proc (reverse sort keys %{$data{$id}}){
printf "%s,%s,%s\n","$id $proc",@{$data{$id}{$proc}};
}
} else {
print OUT "$id- no data\n";
}
}
poj