Deepak Agarwal Deepak Agarwal - 1 year ago 110
Perl Question

undefined subroutine @main::csv error in Text:CSV_XS module

In one of my linux vm boxes the following perl code is failing at line 4

use Text::CSV_XS qw( csv );
my $csv = Text::CSV_XS->new( { binary => 1, eol => "\n" } );
open( $fh, '<:crlf', 'test.csv' ) or die $!;
@lineArray = csv( in => $fh, headers => "auto");
print 'done';

The error states that there is no csv method in main . Errors out as @main::csv undefined subroutine.
This code is working on other installation but not just on one machine.

Perl version is 5.10.1

mob mob
Answer Source

The csv function in Text::CSV_XS was introduced in version 1.04. Check the value of $Text::CSV_XS::VERSION and upgrade if it is older than v1.04.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download