in reply to Using Substitution Operator In Perl Script
Outputs:use Text::CSV_XS; my $csv = Text::CSV_XS->new; while(<DATA>){ chomp; my @columns = split /\t/; $csv->combine( @columns ) or die "could not combine due to ",$csv- +>error_input()," in input\n"; print $csv->string, "\n"; } __DATA__ first second "hello" 100,000 bye He said "bye"
Whereas using tr/\t/,/ will give you:first,second """hello""","100,000" bye,"He said ""bye"""
which is not valid CSV.first,second "hello",100,000 bye,He said "bye"
|
|---|