#!/usr/bin/perl use warnings; use strict; use Net::FTP; my $user='steve'; my $password='...'; my $file='re.pl'; my @clients = qw(localhost example.com); for my $client (@clients){ for (1..3){ my $ftp; eval { $ftp=Net::FTP->new( $client, Timeout => 2, Passive => 1 ) or die "Could not Connect.\n"; $ftp->login ($user, $password); $ftp->binary; $ftp->put($file) or die "Error Uploading.\n"; print "$client done on attempt $_\n"; $ftp->quit; }; last if ! $@; print "$client broke on attempt $_\n"; } } __END__ $ ./ftp.pl localhost done on attempt 1 example.com broke on attempt 1 example.com broke on attempt 2 example.com broke on attempt 3