in reply to Text::CSV_XS -- Bug or wrong usage?
You should report it but in the meantime you can workaround it by omitting the escape character and doing your own escaping. The following example replaces "\:" with $; (char 032) before parsing and then converts it back:
#!/usr/bin/perl -wl use strict; use Text::CSV_XS; my $row = '0005:A:A2:\\\\string 04\\\\'; # Translate escaped : "\:" $row =~ s/\\:/$;/eg; my $csv = Text::CSV_XS->new({'quote_char' => '', 'escape_char' => '', 'sep_char' => ':', 'binary' => 1 }); if ($csv->parse($row)) { my @fields = $csv->fields(); # Replace escaped chars s/$;/\\:/g for @fields; print "$fields[3]\n"; } else { print "Parse failed ", $csv->error_input(); }
--
John.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Text::CSV_XS -- Bug or wrong usage?
by choeppner (Pilgrim) on Mar 28, 2003 at 16:01 UTC |