in reply to Text::CSV_XS and line-endings

the variable $/ can be modified for the \r. this tells perl that \r is the line delimiter instead of \n.

you can test to see which OS you are on with the $ENV{OS};

i hope this helps

Replies are listed 'Best First'.
Re^2: Text::CSV_XS and line-endings
by samtregar (Abbot) on Mar 16, 2006 at 22:21 UTC
    Aside from the fact that $/ doesn't affect Text::CSV_XS, $ENV{OS} won't help here either. The issue is the OS of the person who created the file, not the system running the code!

    -sam

Re^2: Text::CSV_XS and line-endings
by friedo (Prior) on Mar 16, 2006 at 21:55 UTC
    Unfortunately changing $/ doesn't work because Text::CSV_XS does its own low-level parsing. The OS the code is running on is known, the problem is the CSV files can come from anywhere. Thanks for the suggestions though.
Re: Text::CSV_XS and line-endings
by benizi (Hermit) on Mar 18, 2006 at 04:56 UTC

    In addition to the problems pointed out by others (need the OS on which a file was created not the OS on the current machine), you shouldn't rely on $ENV{OS}, even if it happens to be in your environment. It's not set automatically by perl, and doesn't seem to be set in Gentoo Linux, RedHat Linux, OS X, or Solaris. You should use $^O (equivalent to $Config{osname}).

    perl v5.8.7 i386-linux $Config{osname}=$^O=linux $ +ENV{OS}= perl v5.8.4 i686-linux-thread-multi $Config{osname}=$^O=linux $ +ENV{OS}= perl v5.8.7 i686-linux $Config{osname}=$^O=linux $ +ENV{OS}= perl 5.005_03 sun4-solaris $Config{osname}=$^O=solaris $ +ENV{OS}= perl v5.8.6 darwin-thread-multi-2level $Config{osname}=$^O=darwin $ +ENV{OS}=