http://www.perlmonks.org?node_id=789127


in reply to FTP - Download Multiple Files Matching Pattern

You need to download using a fullpath. Add the FTP directory to the filename before you can download it.

foreach(@files) { my $filename = $_; my $fullpath = "$ftpFolder/$filename"; # download the file if ($ftp->get($fullpath)) { # be sure to only delete the file if it successfully downloaded # then delete the file. if ($ftp->unlink($fullpath)) { print "DELETED FILE: [$filename]\n"; } else { print "[Error] UNABLE TO DELETE THE FILE: [$filename][" . $ftp->m +essage . "]\n"; } } else { # error - not able to download print "[Error] UNABLE TO DOWNLOAD FILE: [$filename][" . $ftp->messa +ge . "]\n"; }