I have this little piece of code:
-- CUT --
#!/usr/bin/perl
use strict;
use warnings;
use Net::FTP;
my $address = "localhost";
my $port = 21;
my $user = "test";
my $pass = "test";
my $sourcedir = "/test/";
my $sourcemask = "*";
my $destdir = "/tmp/test/";
my $ftp = Net::FTP->new(
$address,
Timeout => 30,
Debug => 0,
Port => $port,
) or die "Error in connect";
$ftp->login($user, $pass) or die "Error in login";
$ftp->cwd($sourcedir) or die "Error in cwd";
$ftp->binary();
for ($ftp->ls($sourcemask)) {
$ftp->get("$_", "$destdir$_") or die "Error in get";
}
-- CUT --
Now, if I put in some wrong values I get the expected "Error in ****".
The unexpected behaviour happens when the destination directory doesn't
exist and I get this output:
Cannot open Local file /tmp/test/test.xml: No such file or directory
at ./test.pl line 25
Error in get at ./test.pl line 25.
Changing the loop to:
for ($ftp->ls($sourcemask)) {
my $ret = undef;
eval { $ret = $ftp->get($_, "$destdir$_") };
die "Error in get" unless defined $ret;
}
Doesn't work either.
Any way to prevent this other than checking if the destination directory
exists?
Thanks!!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>