At first glance, it looks like all you have to do is to provide a reference:
my $ftp = Net::FTP->new(Host => \@try_these);
but there seems to be something flaky with Net::FTP
here. I am not sure if anyone has tested this. I don't have time to debug it right now, but I would just recommend doing:
my $ftp;
for my $host ( @try_these ) {
warn "Attempting to connect to '$host'\n";
$ftp = Net::FTP->new( $host ) and last;
}
die "Could not connect\n" unless $ftp;
Update: I checked the source code for Net::FTP->new
and there does not seem to be any checks for an array reference passed. This seems to be a case of the code and docs not matching each other.
Bug report filed.
Update:
Subject: Re: [rt.cpan.org #48001] Net::FTP->new(Host => $arrayref) does not work
Date: Sun, 19 Jul 2009 11:35:14 -0500
To: bug-libnet[...]rt.cpan.org
From: Graham Barr [text/plain 147b]
> > Seems like a mismatch between the code and the docs.
>
> Not sure where that came from in the docs, Net::FTP has never supported an
> array of hosts