use Text::CSV_XS; my $csv = new Text::CSV_XS; . . . . . . $csv->combine( $co_id, $company, $item, $date, $person, $value ); print $csv->string, "\n";