in reply to Text::CSV_XS and line-endings
Seems like it should honor $/ but perhaps you can force it like so?IO::Handle->format_line_break_characters( [STR] ) $: IO::Handle->input_record_separator( [STR] ) $/
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?
Also cleaned up some errors in the original portion.#!/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;
Update2: Would something like the following work?
cat mac.txt | perl -e '$/="\r"; while(<>){$_=~s/\015$/\n/; print $_;}'
|
|---|