Dear Brotheren and Sisteren,

I'm getting an error I just don't uderstand using the following code:

#!/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 is:
Use of uninitialized value in -f at /opt/perl/lib/site_perl/5.6.1/Net/ +FTP.pm line 716.
The error points to this section of code in Net::FTP
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 }
The line:
$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.
Does anyone have any ideas?

The file is transfered succesfully, no problem connecting or logging in. The only trouble is the error message.

TIA
Sweetblood


In reply to trouble with uninitialized value and Net::FTP by sweetblood

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.