file: $CPAN/authors/id/H/HM/HMBRAND/Text-CSV_XS-0.40.tgz
size: 85057 bytes
md5: cb8b2af20925b832159f34eed9793666
2008-04-07 0.40 - H.Merijn Brand
* Implemented getline_hr () and column_names () RT 34474
(suggestions accepted from Mark Stosberg)
* Corrected misspelled variable names in XS
* Functions are now =head2 type doc entries (Mark Stosberg)
* Make SetDiag() available to the perl level, so errors can
be centralized and consistent
* Integrate the non-XS errors into XS
* Add t/75_hashref.t
* Testcase for error 2023 (Michael P Randall)
* Completely refactored the XS part of parse/getline, which
is now up to 6% faster. YMMV
* Completed bind_columns. On straight fetches now up to three
times as fast as normal fetches (both using getline ())
getline_hr
The "getline_hr ()" and "column_names ()" methods work together
+ to
allow you to have rows returned as hashrefs. You must call
"column_names ()" first to declare your column names.
$csv->column_names (qw( code name price description ));
$hr = $csv->getline_hr ($io);
print "Price for $hr->{name} is $hr->{price} EUR\n";
"getline_hr ()" will croak if called before "column_names ()".
column_names
Set the keys that will be used in the "getline_hr ()" calls. If
+ no keys
(column names) are passed, it'll return the current setting.
"column_names ()" accepts a list of scalars (the column names)
+or a
single array_ref, so you can pass "getline ()"
$csv->column_names ($csv->getline ($io));
"column_names ()" croaks on invalid arguments.
bind_columns
Takes a list of references to scalars (max 255) to store the fi
+elds
fetched "by getline_hr ()" in. When you don't pass enough refer
+ences to
store the fetched fields in, "getline ()" will fail. If you pas
+s more
than there are fields to return, the remaining references are l
+eft
untouched.
$csv->bind_columns (\$code, \$name, \$price, \$description);
while ($csv->getline ()) {
print "The price of a $name is \x{20ac} $price\n";
}
Enjoy, Have FUN! H.Merijn