A good tool to use if you want to automate the retrieval of getting or putting files on a different server via FTP is the use of the module Net::FTP. I use this to automatically pull certain log files during the day to a log server in a different location, here’s how it works:
#!/usr/bin/perl -w
use Net::FTP;
#FTP vars
my $username = "user";
my $password = "password";
my $site = "foo.com";
my $file1 = "sample.log";
$ftp = Net::FTP->new("$site", Debug => 0)
or die "Cannot connect to $site: $@";
$ftp->login("$username","$password")
or die "Cannot login ", $ftp->message;
$ftp->binary
or die "Cannot change to binary format ",$ftp->message;
$ftp->get("$file1")
or die "get failed ", $ftp->message;
print "Got $file1...\n";
$ftp->quit;