It's been a awhile since I used Text::CSV_XS, but don't you create an IO::File instance and then pass that to yout Text::CSV instance? If so then would the following from IO::Handle do what you want? They are about halfway down the page.
IO::Handle->format_line_break_characters( [STR] ) $: IO::Handle->input_record_separator( [STR] ) $/
Seems like it should honor $/ but perhaps you can force it like so?
IO::Handle->input_record_separator( ["\r"] );

Update1: Looks like this is what you want. However, Text::CSV_XS seems to somehow ignore line 7. According to the Text::CV_XS documentation the IO::Handle->getline is what is called, so the above should in theory work. However, $csv->getline returns undef on my simulated MAC test file. Looks like the Decode routine in the .so may be the culprit?

#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; use IO::File; use Text::CSV_XS; IO::Handle->input_record_separator( "\r" ); my $file = defined $ARGV[0] ? $ARGV[0] : 'normal.txt'; my $io = new IO::File "$file", "<" || die "horribly"; my $csv = new Text::CSV_XS; # my $test = $io->getline; # print Data::Dumper->Dump([$test],['io']); my $columns = $csv->getline($io); print Data::Dumper->Dump([$columns],['csv']); exit 0;
Also cleaned up some errors in the original portion.

Update2: Would something like the following work?

cat mac.txt | perl -e '$/="\r"; while(<>){$_=~s/\015$/\n/; print $_;}'

In reply to Re: Text::CSV_XS and line-endings by Argel
in thread Text::CSV_XS and line-endings by friedo

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.