I've seen that complaint before, which is odd because the docs clearly tell you how to write a CSV, as well. The first sentence of the description says so specifically. The functions you want are combine (into a CSV string) or, more likely, print (combine and then print to a filehandle).
Here's a simple example:
@headers = (
"First",
"Second",
"Third",
"Fourth"
);
@cols = (
"I'm text",
12, # <--Number
"",
"That was a blank"
);
my $csv = Text::CSV_XS->new;
open my $fh, ">Output.csv" or die $!;
$csv->print($fh, @headers); # Prints with \n by default
$csv->print($fh, @cols); # Use something like
# $csv->print($fh, @$_) for @rows
# for an array of data.
Output.csv should look like this:
"First","Second","Third","Fourth"
"I'm text",12,,"That was a blank"
Cheers!
--marmot
UPDATED: for clarity and to correct a typo. |