Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Answer: How do I create a CSV from a 2D array?

( #86770=categorized answer: print w/ replies, xml ) Need Help??

Q&A > arrays > How do I create a CSV from a 2D array? contributed by fenonn

As long as @data is a 2D array this statement will store the data in CSV form in the scalar $temp so that it can be printed out to a file.
$temp = join "\n", map { $_ = join ",", @{$_} } @data;

Comment on Answer: How do I create a CSV from a 2D array?
Download Code
Re: Answer: How do I create a CSV from a 2D array?
by hossman (Prior) on May 29, 2003 at 23:52 UTC
    This doesn't account for field values which may contain double-quotes, single-quotes, commas, or embedded newlines.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2015-07-06 11:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (73 votes), past polls