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

I keep getting the following error while FTP'ing the libs.Has anyone seen this before ?Please advise.

Cannot open Local file //lab/data.lib Invalid argument failed Opening BINARY mode data connection for data.lib

$ftp->cwd("/mnt/lib") or die "Cannot change working directory ", $ftp- +>message; $ftp->binary(); for my $file (@libs) { $ftp->put("$file") or die "put failed ", $ftp->messa +ge; }

Replies are listed 'Best First'.
Re: Cannot open local file error while FTP.ing
by Khen1950fx (Canon) on May 26, 2011 at 04:23 UTC
    First, get in the habit of posting a workable snippet. You'll get a better response that way. Second, avoid useless use of interpolation such as  $ftp->put("$file"). Try something like this:
    !/usr/bin/perl use strict; use warnings; use Net::FTP; use constant HOST => 'ftp.cpan.org'; use constant DIR => '/mnt/lib'; use constant FILES => 'libs'; my $ftp = Net::FTP->new( HOST, Debug => 1, Passive => 1, Timeout => 1 ); $ftp->login('anonymous'); $ftp->cwd(DIR); $ftp->binary; foreach my $file(FILES) { $ftp->put($file) or die "$@\n"; } $ftp->quit;