# Pattern match all .ipup files in local directory my @files = glob("*.ipup"); # Declare $ftp my $ftp; $ftp = Net::FTP->new($ulservername, Debug => 1, Timeout => 120, Hash => \*STDERR) or die "Cannot connect the FTP server called $ulservername.\n"; $ftp->login($username,$password) or die "Authentication on $ulservername failed\n"; $ftp->binary() or die "Could not set BINARY command on $ulservername\n"; $ftp->cwd($rdirectory) or die "Could change working directory on $ulservername\n"; # Execute the FTP transfer foreach my $file (@files) { print "Copying $file to FTP server...\n"; $ftp->pasv() or die "Could not set PASV command on $ulservername\n"; $ftp->put($file, $file) or die "Could not transfer $file to FTP server: $!\n"; } # Send quit to FTP server $ftp->quit() or die "Could not quit the FTP session. Que sera sera\n";