in reply to CSV_XS issue
Finally, from a stylistic point of view, you're calling main and then declaring it a line later .. you can just skip both of those steps. Here's how I would re-format your code..
use strict; use warnings; use Text::CSV_XS; { my @row1 = ("aaa","fff","sss" ); my @row2 = ("bbb","fff","sss"); # should set binary att my $csv = Text::CSV_XS->new ( { binary => 1 } ) or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $fh, ">:encoding(utf8)", "new.csv" or die "Failed to open new.csv for writing: $!"; $csv->print ($fh, \@row1); $csv->print ($fh, \@row2); close $fh or die "Failed to close new.csv: $!"; print " finished \n"; }
You could get more cleanup by using perltidy -- I'm a fan of this utility.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: CSV_XS issue
by anaconda_wly (Scribe) on Apr 08, 2013 at 03:25 UTC |