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

I've been trying to transfer 3 files from a local host to a remote host. I am able to successfully connect to the remote host. However, when I try to use "put", I encounter an error.
Here's a snippet of my code.

my %args = ( user => "uname", password => "pword" ); my $sftp = Net::SFTP::Foreign::Compat->new($rhost, %args); $sftp->die_on_error("Unable to establish connection"); for(@files) { my $filename = basename($_); my $remotefile = $rdir . $filename; $sftp->put($_, $remotefile); }

I get this error

Use of uninitialized value in numeric ne (!=) at /usr/opt/Perl5_10/lib +/perl5/site_perl/5.10.1/Net/SFTP/Foreign/Common.pm line 79. Use of uninitialized value in numeric ne (!=) at /usr/opt/Perl5_10/lib +/perl5/site_perl/5.10.1/Net/SFTP/Foreign/Common.pm line 79. Use of uninitialized value in numeric ne (!=) at /usr/opt/Perl5_10/lib +/perl5/site_perl/5.10.1/Net/SFTP/Foreign/Common.pm line 79. Use of uninitialized value in numeric ne (!=) at /usr/opt/Perl5_10/lib +/perl5/site_perl/5.10.1/Net/SFTP/Foreign/Common.pm line 79. Use of uninitialized value in numeric ne (!=) at /usr/opt/Perl5_10/lib +/perl5/site_perl/5.10.1/Net/SFTP/Foreign/Common.pm line 79. Use of uninitialized value in numeric ne (!=) at /usr/opt/Perl5_10/lib +/perl5/site_perl/5.10.1/Net/SFTP/Foreign/Common.pm line 79.

This is what's in Common.pm line 79-81

if ($sftp->{_error} != Net::SFTP::Foreign::Constants::SFTP_ERR_CONNECT +ION_BROKEN()) { $sftp->{_error} = 0; }

Replies are listed 'Best First'.
Re: Problem with "put" in Net::SFTP::Foreign::Compat
by salva (Canon) on Apr 29, 2013 at 11:51 UTC
    This is a harmless warning you can safely ignore. It is caused by a (harmless) bug on the module that I have just fixed in version 1.76_02.

    In any case, die_on_error is not on Net::SFTP API. If you are using Net::SFTP::Foreign::Compat you should stick to that. Though, If you are writing your module from scratch, just use the much friendly Net::SFTP::Foreign module.

Re: Problem with "put" in Net::SFTP::Foreign::Compat
by Anonymous Monk on Apr 29, 2013 at 11:37 UTC

    I get this error

    that is a warning, the kind of error that doesn't end your program -- is it important? Probably not

    This is what's in Common.pm line 79-81

    It doesn't matter. It appears you turned on warnings globally and you shouldn't do that. don't turn on warnings for code you did not write esp if the code does  no warnings 'uninitialized';