% steph@apexPDell2 (/home/stephan) % % cat conv_comma2pipe_xs.px #!/usr/bin/perl use strict; use warnings; $|++; #use IO::Handle; use IO::Wrap; use Text::CSV_XS; # use DDS; # my $in = IO::Wrap::wraphandle(\*STDIN) or die; # my $out = IO::Wrap::wraphandle(\*STDOUT) or die; # Dump\($in, $out); my $csv_in = Text::CSV_XS->new({ binary => 1, }) or die; my $csv_out = Text::CSV_XS->new({ binary => 1, sep_char => q{|}, eol => qq{\n}, }) or die; while (defined (my $rec = $csv_in->getline(\*STDIN)) ) { { my @fields = @$rec; local $"=q{][}; print {\*STDERR} ".rec [@fields]\n"; } $csv_out->print(\*STDOUT, $rec); } __END__ % steph@apexPDell2 (/home/stephan) % % cat hi1.csv | perl+ -w conv_comma2pipe_xs.px .rec [a][b][c] a|b|c .rec [a][okay, comma][c] a|"okay, comma"|c .rec [a][long line, indeed][end] a|"long line, indeed"|end % steph@apexPDell2 (/home/stephan) % % cat hi1.csv a,b,c a,"okay, comma",c a,"long line, indeed",end