Reputation: 933
I'm currently optimizing and maintaining a Perl script used to analyze two CSV files for different data. After it's done analyzing the data, the various results are written out to CSV files. However, depending on certain command line flags, the data to be written will be separated by either a comma (,) or a pipe (|). Because of this, the code is a bit convoluted (mostly because the members of my business unit can't code properly to save their lives, but I digress...). I'm wondering if there is a Perl module found somewhere that allows you to read/write files from/to a CSV file, where the delimiters can be configured. I know that Python has a built-in CSV module that allows such functionality and flexibility. When I searched through CPAN, I found the Text::CSV module, but this doesn't seem to allow me to configure the delimiter.
Any thoughts?
Upvotes: 1
Views: 692
Reputation: 53573
This should work:
my $csv = Text::CSV->new({
'escape_char' => '\\',
'quote_char' => '"',
'sep_char' => ','
});
Upvotes: 8