in reply to Converting a delimited file.

Maybe you want to remove the empty fields before you output them?

my @output= grep {/\S/} @file_line_contents; print OUTFILE1 "\"$coid\"\,\"".join ('","', @output);

But for writing CSV, you really want to look at Text::CSV.