while ( $line = ) { unless (($data[10] =~ m/Pending=/) || ($data[6] =~ m/Gap/)) { next; } # skip elements we don't want if ($line =~ m/Pending=/) { my @data=split(/ /,$line); # split the line up $data[10] =~ s/[A-Za-z=.]//g; # delete "Pending", "=" and "." $data[1] =~ s/\..*//g; # delete the millisecond element of the (line)lTime var my @lTime=split(/:/,$data[1]); # split the line time my $lSecs=$lTime[0] * 3600 + $lTime[1] * 60 + $lTime[2]; # convert line-time to seconds if (($data[0] eq $ymd) && ($data[10] >= $tHold) && ($lSecs >= $sSecs) && ($lSecs <= $eSecs)) { $line = "$data[1],$data[10]"; } }