I've had good results with Net::FTP::Robust; however, most of the ftp servers that I use are set up to retrieve or accept files only. You'll see "I can only retrieve regular files" in this script:
#!/usr/bin/perl
use strict;
use warnings;
use Net::FTP::Robust;
use Log::Report;
use constant HOST => 'ftp.perl.org';
use constant DIR => '/pub/CPAN';
use constant FILE => 'README';
my $ftp = Net::FTP->new(HOST, Debug => 1, Passive => 1)
or die "Couldn't connect: $@\n";
$ftp->login('anonymous');
$ftp->cwd(DIR);
$ftp->get(DIR);
try { "error" };
if($@) { '../CPAN' }
$ftp->quit;
Update: You can dramatically speed up file transfer by using Net::FTP::Throttle
Try this:
#!/usr/bin/perl
use strict;
use warnings;
use Net::FTP::Robust;
use Net::FTP::Throttle;
use Log::Report;
use constant HOST => 'ftp.perl.org';
use constant DIR => '/pub/CPAN';
use constant FILE => 'README';
my $ftp = Net::FTP->new(HOST, Debug => 1, Passive => 1,
MegabitsPerSecond => 2) or die "Couldn't connect: $@\n";
$ftp->login('anonymous');
$ftp->cwd(DIR);
$ftp->get(FILE);
try { "error" };
if($@) { '../CPAN' }
$ftp->quit;
|