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.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Replies are listed 'Best First'.
Re^2: CSV_XS issue
by anaconda_wly (Scribe) on Apr 08, 2013 at 03:25 UTC
    Yes, thanks for the reformatting. I used to be c\c++ programmer. So I have some habbit incompatible with the Perl like the main and variable declaration and I'm in haste by the little snippet to find the correct usage. Good to know the perl style programming and your experience sharing. That's really cool to me!