http://www.perlmonks.org?node_id=579961

rbi has asked for the wisdom of the Perl Monks concerning the following question:

After I kindly got a solution to a Net::FTP problem I got, I could move to the next one :))
Considering this code:
... my $ftp = Net::FTP->new($hostname, Debug => 1, Passive => 1); $ftp->login($user,$password); $ftp->cwd($directory); my $ref= $ftp->ls(); die Dumper($ref);
If the $directory is empty, on Linux I get:
Can't use an undefined value as a symbol reference at /usr/lib/perl5/5 +.8.8/Net/FTP/dataconn.pm line 53.
Instead on Windows I get correctly:
$VAR1 = undef;
How could I fix this behaviour on Linux ? Thanks for any hint/explaination.

Replies are listed 'Best First'.
Re: Net::FTP behavior under Linux and Windows
by blazar (Canon) on Oct 23, 2006 at 12:07 UTC
    How could I fix this behaviour on Linux ? Thanks for any hint/explaination.

    First of all, are the versions of Perl respectively in Windows and in Linux the same? How 'bout the versions of Net::FTP and Data::Dumper?

    kirk:~ [14:06:30]$ perl -V:osname osname='linux'; kirk:~ [14:06:36]$ perl -MData::Dumper -e 'print Dumper undef' $VAR1 = undef;
      Perl version is v5.8.8 built for x86_64-linux-thread-multi and MSWin32-x86-multi-thread, respectively.
      Net::FTP is 2.75 on both PCs
      Data::Dumper is 2.121_08 on both PCs (but it behaves that way also not using Data::Dumper).<br/
Re: Net::FTP behavior under Linux and Windows
by Anonymous Monk on Oct 23, 2006 at 13:35 UTC
    What is your shebang?
      #!/usr/bin/perl