<?xml version="1.0" encoding="windows-1252"?>
<node id="618129" title="Re: The future of Text::CSV_XS - TODO" created="2007-05-30 04:17:44" updated="2007-05-30 00:17:44">
<type id="11">
note</type>
<author id="200365">
Tux</author>
<data>
<field name="doctext">
&lt;p&gt;Small updates&lt;/p&gt;
&lt;p&gt;I now understand the fuzz people make about embedded newlines. [mod://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 &lt;i&gt;reading&lt;/i&gt; the line in the perl script. Obviously,&lt;/p&gt;
&lt;code&gt;
  my $csv = Text::CSV_XS-New ({ binary =&gt; 1 });
  while (&lt;&gt;) {
      $csv-&gt;parse ($_);
      my @fields = $csv-&gt;fields ();
&lt;/code&gt;
&lt;p&gt;Will horribly fail, as &lt;c&gt;&lt;&gt;&lt;/c&gt; will break too early.&lt;/p&gt;
&lt;p&gt;The most recent [http://www.xs4all.nl/~hmbrand/Text-CSV_XS-0.27.tar.gz|snapshot] now contains a &lt;c&gt;t/45_eol.t&lt;/c&gt;, 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:&lt;/p&gt;
&lt;code&gt;
  use IO::Handle;
  my $csv = Text::CSV_XS-&gt;new ({ binary =&gt; 1, eol =&gt; $/ });
  while (my $row = $csv-&gt;getline (*ARGV)) {
      my @fields = @$row;
&lt;/code&gt;
&lt;p&gt;or, if you open files yourself, like:&lt;/p&gt;
&lt;code&gt;
  my $csv = Text::CSV_XS-&gt;new ({ binary =&gt; 1, eol =&gt; $/ });
  open my $io, "&lt;", $file or die "$file: $!";
  while (my $row = $csv-&gt;getline ($io)) {
      my @fields = @$row;
&lt;/code&gt;
&lt;p&gt;I'm still thinking about the best way to add this to the docs.&lt;/p&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-200365"&gt;
&lt;br /&gt;
Enjoy, Have FUN! H.Merijn
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
617577</field>
<field name="parent_node">
617577</field>
</data>
</node>
