2007-05-07 H.Merijn Brand (0.25) * Merijn got the maintainership - code reformat and code cleanup - renamed internal (Encode, Decode) to (Combine, Parse) to prevent misinterpretation with upcoming Unicode changes and possible name clashes - added pod check (and fixed pod) - added pod coverage and small additions to the pod. More to do in this area - renamed test to fixate the sequence - Added t/50_utf8.t - tests now use Test::More . Makefile.PL requires Test::More - checked proclaimed version compatibility . 5.9.x-64int works @31159 . 5.8.x-64int-dor works @31162 . 5.8.0-dor works . 5.6.2 works . 5.005.04 works . 5.004.05 fails - 5.005 is now prerequisite - Added missing info in docs for new () - Added meta_info () method and docs - Added keep_meta_info in new () - Added t/15_flags.t - Added test_cover make target - Added test for error_input () - Added tests for fields () and meta_info () before parse () - Added tests for ->types () as method - Added tests for deleting types (coverage now over 99%) - Added is_quoted (), is_binary () and tests - Added COPYRIGHT section to pod - Added the parse example from the pod to test.pl - Added accessor methods for internals: quote_char () et all - Added tests for the new accessor methods - Added always_quote to the missing places in the doc and in new () - Changed the tests to use the accessors instead of the hash keys except for the ->{types} and ->{_types} - Moved test.pl to examples/speed.pl #### $csv = Text::CSV_XS->new (); is equivalent to $csv = Text::CSV_XS->new ({ quote_char => '"', escape_char => '"', sep_char => ';,', eol => '', always_quote => 0, binary => 0, keep_meta_info => 0, }); For all of the above mentioned flags, there is an accessor method available where you can inquire for the current value, or change the value my $quote = $csv->quote_char; $csv'>binary (1); : : meta_info @flags = $csv->meta_info (); This object function returns the flags of the input to "combine ()" or the flags of the resultant decomposed fields of "parse ()", whichever was called more recently. For each field, a meta_info field will hold flags that tell something about the field returned by the "fields ()" method or passed to the "combine ()" method. The flags are bitwise 'or'd like: 0x0001 The field was quoted. 0x0002 The field was binary. See the "is_*** ()" methods below. is_quoted my $quoted = $csv->is_quoted ($column_idx); Where $column_idx is the (zero-based) index of the column in the last result of "parse ()". This returns a true value if the data in the indicated column was enclused in "quote_char" quotes. This might be important for data where ",20070108," is to be treated as a numeric value, and where ","20070108"," is explicitely marked as character string data. is_binary my $binary = $csv->is_binary ($column_idx); Where $column_idx is the (zero-based) index of the column in the last result of "parse ()". This returns a true value if the data in the indicated column contained any byte in the range [\x00-\x08,\x10-\x1F,\x7F-\xFF] An example for parsing CSV lines: use Text::CSV_XS; my $csv = Text::CSV_XS->new ({ keep_meta_info => 1, binary => 1 }); my $sample_input_string = qq{"I said, ""Hi!""",Yes,"",2.34,,"1.09","\x{20ac}",}; if ($csv->parse ($sample_input_string)) { my @field = $csv->fields; foreach my $col (0 .. $#field) { my $quo = $csv->is_quoted ($col) ? $csv->{quote_char} : ""; printf "%2d: %s%s%s\n", $col, $quo, $field[$col], $quo; } } else { my $err = $csv->error_input; print "parse () failed on argument: ", $err, "\n"; }