ANNOUNCE: Text-CSV_XS 0.43

ANNOUNCE: Text-CSV_XS 0.43

am 22.04.2008 18:01:57 von h.m.brand

On popular demand ...

file: $CPAN/authors/id/H/HM/HMBRAND/Text-CSV_XS-0.43.tgz
size: 87473 bytes
md5: 47f9a2011dd0afba7cb0ee967a592aa3

2008-04-21 0.43 - H.Merijn Brand

* parse errors try to remember failing position
* used valgrind to test for leaks (devel-only)
* used Test::Valgrind as alternative leak check (devel-only)
* improve documentation for error 2023
* nailed the loose quotes in quoted fields

2008-04-16 0.42 - H.Merijn Brand

* Generate META.yml myself. I won't use Build.PL
* Array-refs now accept scalars with magic:
$csv->print (*STDOUT, $sth->{NAME_lc});
* More/better examples
* Added t/76_magic.t

Some highlights ...

allow_loose_quotes
By default, parsing fields that have "quote_char" characters inside
an unquoted field, like

1,foo "bar" baz,42

would result in a parse error. Though it is still bad practice to
allow this format, we cannot help there are some vendors that make
their applications spit out lines styled like this.

In case there is really bad CSV data, like

1,"foo "bar" baz",42

or

1,""foo bar baz"",42

there is a way to get that parsed, and leave the quotes inside the
quoted field as$,1rp(Bis. This can be achieved by setting
"allow_loose_quotes" AND making sure that the "escape_char" is not
equal to "quote_char".

error_diag

Text::CSV_XS$,1x2(B>error_diag ();
$csv$,1x2(B>error_diag ();
$error_code = 0 + $csv$,1x2(B>error_diag ();
$error_str = "" . $csv$,1x2(B>error_diag ();
($cde, $str, $pos) = $csv$,1x2(B>error_diag ();

If (and only if) an error occured, this function returns the
diagnostics of that error.

If called in void context, it will print the internal error code and
the associated error message to STDERR.

If called in list context, it will return the error code and the error
message in that order. If the last error was from parsing, the third
value returned is the best guess at the location within the line that
was being parsed. It$,1ry(Bs value is 1$,1x2(Bbased.

If called in scalar context, it will return the diagnostics in a single
scalar, a$,1x2(Bla $!. It will contain the error code in numeric context, and
the diagnostics message in string context.

When called as a class method or a direct function call, the error diag
is that of the last "new ()" call.

SetDiag

$csv$,1x2(B>SetDiag (0);

Use to reset the diagnosticts if you are dealing with errors.