Here is some Working code, and the output it produces:
#!/usr/bin/perl use strict; use warnings; use Text::CSV; my $csv = Text::CSV->new({ sep_char => ',', quote_char => undef , esc +ape_char=>undef }); while (my $line = <DATA>){ if ($csv->parse($line)) { my @fields = $csv->fields(); print "$fields[0],"; print "$fields[1],"; print "$fields[2]\n"; } else { warn "Line could not be parsed: '$line'\n"; my ($cde, $str, $pos, $rec, $fld) = $csv->error_diag (); print "DIAG:(CDE=$cde, STR=$str, POS=$pos, REC=$rec, FLD=$fld)\n +" } } __DATA__ 0,""Rat Control" <sip:+15559999999@192.168 .5.233>;tag=gK004bb052",9
The quotes at the start of Rat Control are problematic, and produce this error on default settings:>perl test2.pl 0,""Rat Control" <sip:+15559999999@192.168 .5.233>;tag=gK004bb052",9
...Disinformation is not as good as datinformation. Don't document the program; program the document.
In reply to Re^3: Multiple double quotes within csv
by NetWallah
in thread Multiple double quotes within csv
by mhooper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |