if ($array[0] eq $requestid) { if ($enddate) { $array[9]= $enddate;} if ($state) { $array[10]=$state;} } print join(",",@array); print "\n";