in reply to Converting a delimited file.

From your description of your data I imply that there are two consecutive commas in each line, either after field 3 or before field 4. You could just s/,,/,/; on each line.

Update: While you are at it you could also add quotes around the remaining commas and print the line:

while(<INFILE1>) { chomp; s/,,/,/; s/,/","/g; print OUTFILE1 "\"$coid\",\"$_\"\n"; }