sweetblood has asked for the wisdom of the Perl Monks concerning the following question:
I'm getting an error I just don't uderstand using the following code:
The error is:#!/usr/bin/perl -w use strict; use Net::FTP; my $ftp = Net::FTP->new('ftp') or die("unable to connect: $@\n"); $ftp->login or die("Unable to login to ny4"); print "Message = ", $ftp->message(), "\n"; $ftp->put( 'foo' ) or die("Unable to write ftp.prep"); print "Message = ", $ftp->message(), "\n"; $ftp->quit;
The error points to this section of code in Net::FTPUse of uninitialized value in -f at /opt/perl/lib/site_perl/5.6.1/Net/ +FTP.pm line 716.
The line:sub _store_cmd { my($ftp,$cmd,$local,$remote) = @_; my($loc,$sock,$len,$buf); local *FD; my $localfd = ref($local) || ref(\$local) eq "GLOB"; unless(defined $remote) { croak 'Must specify remote filename with stream input' if $localfd; require File::Basename; $remote = File::Basename::basename($local); } if( defined ${*$ftp}{'net_ftp_allo'} ) { delete ${*$ftp}{'net_ftp_allo'}; } else { # if the user hasn't already invoked the alloc method since the las +t # _store_cmd call, figure out if the local file is a regular file(n +ot # a pipe, or device) and if so get the file size from stat, and sen +d # an ALLO command before sending the STOR, STOU, or APPE command. $ftp->_ALLO(-s _) if -f $loc; # no ALLO if sending data from a pipe }
is line 716, as mentioned in the error message. From what I can tell $loc is not set in the preceding code.$ftp->_ALLO(-s _) if -f $loc; # no ALLO if sending data from a pipe
The file is transfered succesfully, no problem connecting or logging in. The only trouble is the error message.
TIA
Sweetblood
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: trouble with uninitialized value and Net::FTP
by YetAnotherDave (Beadle) on Jan 15, 2005 at 00:21 UTC |