That code would fail if *any* of the lines contains embedded newlines.

I'd simplify the code to this, assuming the header has no embedded newlines:

my $csv = Text::CSV_XS->new ({ binary => 1, decode_utf8 => 1, auto_diag => 1, allow_loose_quotes => 1, }); open my $data, "<:encoding(utf-8)", $file or die "$file: $!\n"; my $ref; my @header = $csv->header ($data); while (my $row = $csv->getline ($data)) { push @$ref, $row; }

In CSV don't let perl deal with the EOL. In Text::CSV and Text::CSV_XS the differences between Windows EOL and Linux EOL aur fully automatically dealt with within the definition of legal CSV.

I cannot tell anything about inappropriate ioctl calls regarding to CSV parsing. Neither on Linux nor on Windows. If the error is reproducable, I'd need the CSV file in full (preferably in a ZIP to ensure no binary conversions take place).


Enjoy, Have FUN! H.Merijn

In reply to Re^3: Need to sort comma delimited, double quoted file by Tux
in thread Need to sort comma delimited, double quoted file by CSharma

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.