Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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

by ichimunki (Priest)
on Dec 14, 2000 at 05:24 UTC ( #46542=categorized answer: print w/replies, xml ) Need Help??

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

As long as you are sure the list is two dimensional, this should work. First argument is the delimiter, second is the array. If you print the returned scalar to a filehandle, you will create a .csv file:
my $write_this_to_file = delimit( ", ", @array ); sub delimit { my $delim = shift; my $delimited_file; foreach $row (@_) { $delimited_file .= join ($delim, @$row); $delimited_file .= "\n"; } return $delimited_file; }

Log In?

What's my password?
Create A New User
[Jeri]: heyyyy!!!!
[Jeri]: I'm about to leave work!!!
[Jeri]: wooooo hooooo!

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2017-02-23 21:44 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (351 votes). Check out past polls.