Small updates
I now understand the fuzz people make about embedded newlines. Text::CSV_XS has always been able to deal with that (well, maybe not always, but at least for a long time already). The problem that people might have is reading the line in the perl script. Obviously,
my $csv = Text::CSV_XS-New ({ binary => 1 });
while (<>) {
$csv->parse ($_);
my @fields = $csv->fields ();
Will horribly fail, as <> will break too early.
The most recent snapshot now contains a t/45_eol.t, that tests all possible eol combinations. Have a look to see that the way to parse CSV with embedded newlines should be done similar to:
use IO::Handle;
my $csv = Text::CSV_XS->new ({ binary => 1, eol => $/ });
while (my $row = $csv->getline (*ARGV)) {
my @fields = @$row;
or, if you open files yourself, like:
my $csv = Text::CSV_XS->new ({ binary => 1, eol => $/ });
open my $io, "<", $file or die "$file: $!";
while (my $row = $csv->getline ($io)) {
my @fields = @$row;
I'm still thinking about the best way to add this to the docs.
Enjoy, Have FUN! H.Merijn
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.