undefined value as a symbol reference at Net/FTP/dataconn.pm line 55

Posted by BobK on 2007-10-24 10:24

I have just downloaded and installed the latest ActiveState Perl. I'm trying to create a script that will automatically upload a file via ftp.

I get the following error:
Can't use an undefined value as a symbol reference at C:/Perl/lib/Net/FTP/dataconn.pm line 55.

perl --version:
v5.8.8 MSWin32-x86-multi-thread

binary build 822 [280952] built on Jul 31 2007 19:34:48

The remote ftp site gets the file name in the right location, but its empty. Prior to seeing this error, the program appears to stall for several seconds.

So I know I'm logging in correctly, and the makedir and cwd are working.

Searching for this error on Google, I found several related hits having to do with automated CPAN testing finding this same or similar issue.

Please let me know how to proceed to resolve this.
Many thanks!

xiaohuforever | Tue, 2007-10-30 20:32

I met with the same problem as you, then I installed the module Net::FTP::blat and Net::FTP::Common. After that, I didn't chang any part of my code, and still use Net::FTP but the error didn't occur any more, so I think it's something about inheritance between Net::FTP and its sub packages.
may be you should have a try.Good luck!

marcsinfo | Fri, 2008-09-05 01:37


I had the same error on w2kserver. And the hint from xiaohuforever did not work.

On an winXP system with the same perl installation 5.10.0 the same code is running fine.

Any idea?


marcsinfo | Fri, 2008-09-05 01:50

:-) I solved the problem using the "Passive" Parameter.
The error occurs when Passive is 1 - and occurs not if Passive is 0.

my $ftp = Net::FTP->new($server, Debug => 0, Passive => 0)

Maybe the reason is a firewall problem in the active case. I'm not sure.


peng.wei | Sun, 2010-08-15 22:11

my $ftp2 = Net::FTP->new(Host =>$hostname2, Debug => 1, Port => 21,Passive => 0);

no help.

Passive => 0, triggerred other issue:
Can't call method "sockport" on an undefined value at C:/Perl/lib/Net/FTP.pm line 808.

peng.wei | Sun, 2010-08-15 22:44

my $ftp2 = Net::FTP->new(Host =>$hostname2, Debug => 0, Passive => 0);

Can't call method "sockport" on an undefined value at C:/Perl/lib/Net/FTP.pm line 808.

Jamie.Rosenstee... | Wed, 2011-06-29 07:07

I had a program that's been running in production for years inexplicably return this error when run against a more recent version of ActivePerl.

Explicitly defining the debug and passive state when creating the FTP object, as Marc suggested, resolved the issue.


peng.wei | Sun, 2010-08-15 22:07

D:\perl_test>ppm install --area perl Net::FTP::Common
Downloading ActiveState Package Repository packlist...done
Updating ActiveState Package Repository database...done
Downloading Net-FTP-Common-7.0.d...done
Unpacking Net-FTP-Common-7.0.d...done
Generating HTML for Net-FTP-Common-7.0.d...done
Updating files in perl area...done
4 files installed

D:\perl_test>ppm install --area perl NET::Ftp::Blat
Downloading Net-FTP-blat-0.02...done
Unpacking Net-FTP-blat-0.02...done
Generating HTML for Net-FTP-blat-0.02...done
Updating files in perl area...done
2 files installed

No improve, problem still.

ed_ward_graham | Thu, 2010-02-18 04:39

Excellent post, Marc -- still proving useful here in 2010! That solved my problem, too.

peng.wei | Sun, 2010-08-15 21:56

Can't use an undefined value as a symbol reference at C:/Perl/lib/Net/FTP/dataconn.pm line 54.

my perl version:
D:\>perl -V
Summary of my perl5 (revision 5 version 10 subversion 1) configuration:

osname=MSWin32, osvers=5.00, archname=MSWin32-x86-multi-thread
hint=recommended, useposix=true, d_sigaction=undef
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
optimize='-MD -Zi -DNDEBUG -O1',
ccversion='12.0.8168', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -libpath:"C:\Perl\lib\CORE" -machine:x86'
libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws2_
2.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib
s2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl510.lib
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -libpath:"C:\Perl\lib\CORE" -machine:x86'

Characteristics of this binary (from libperl):
Locally applied patches:
ActivePerl Build 1007 [291969]
0abd0d disable non-unicode case insensitive trie matching
Built under MSWin32
Compiled at Jan 26 2010 23:15:11


I am using the NET:Ftp to fetch file from ftp server:

peng.wei | Sun, 2010-08-15 22:41

after upgrade to 5.12, still not any help.

Can't use an undefined value as a symbol reference at C:/Perl/lib/Net/FTP/dataconn.pm line 54.

D:\perl_test>perl -v

This is perl 5, version 12, subversion 1 (v5.12.1) built for MSWin32-x86-multi-thread
(with 3 registered patches, see perl -V for more detail)

Copyright 1987-2010, Larry Wall

Binary build 1201 [292674] provided by ActiveState http://www.ActiveState.com
Built May 14 2010 00:34:27

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.


peng.wei | Sun, 2010-08-15 23:31

but how firewall trigger this issue?

and how to avoid it?

I do behind of firewall, but I have an "Microsoft Firewall Client for ISA Server" installed on my Desktop PC.

And I can fetch some files down, using my perl app, but other files alarm these issue.

And this perl app can work fine on one server locate at internal network.

sam_u_well | Thu, 2011-12-22 10:53

It seems that this error hits every 6 months or so. I have no idea why it triggers.
I restart my application and it works for many months and then this error pops up.

If I cannot open an FTP handle, the code will exit. If I fail to Login, an ftp->quit happens and the routine exits.

So where can I be picking up this undefined value being picked up from.
Is the FTP data collected a null string?

The error occurs at line 54 of Dataconn.pm.

Shown below is the code around the error from Dataconn.pm which is under FTP/Net.
I do not recall this error ever occuring in Perl 5.10 but it occuring in Perl 5.12.4.
The application is built with Perl Devkit.

If any sees something, that will be great.
Despite purchasing a $300 support agreement from Active State, they refused to look at this. They claimed it was a coding error and I need to go to the forums.

Well the error message does not help!


sub _close {
my $data = shift;
my $ftp = ${*$data}{'net_ftp_cmd'};


delete ${*$ftp}{'net_ftp_dataconn'} ##### This is line 54
if exists ${*$ftp}{'net_ftp_dataconn'}
&& $data == ${*$ftp}{'net_ftp_dataconn'};

sub close {
my $data = shift;
my $ftp = ${*$data}{'net_ftp_cmd'};

if (exists ${*$data}{'net_ftp_bytesread'} && !${*$data}{'net_ftp_eof'}) {
my $junk;
$data->read($junk, 1, 0);
return $data->abort unless ${*$data}{'net_ftp_eof'};


$ftp->response() == CMD_OK
&& $ftp->message =~ /unique file name:\s*(\S*)\s*\)/
&& (${*$ftp}{'net_ftp_unique'} = $1);

$ftp->status == CMD_OK;

peng.wei | Mon, 2012-11-12 16:50

Passive =>0 can solve some case, particular for some ftp site

yangdq@gnetis.com | Sun, 2014-05-11 18:24

Passive => 0 work for me.system is win2003.
router acl policy:client can access FTP server with port rang 20 21.

luiyi2manu@gmail.com | Thu, 2017-03-16 15:56

it works for my scrip passive=> 0, thanks to help us.