问题
Can anybody tell me what is wrong with this code?
As far as concern about as I know @zipFiles = grep /zip/, $ftp->dir;
is creating a prob but if I will remove this part then I will not have any thing for using regex part.
Error : <"Time, file_created_date, File_size, File_name"> file is not found.
use Net::FTP;
#use File::Copy;
$Login = "<redacted>";
$Pwd = "<redacted>";
$ftpHost = "<redacted>";
$ftpFolder = "/daj/dhakj/ahdakl/abc_201206_def_05";
$ftp = Net::FTP->new( $ftpHost, Timeout => 100 );
if ($ftp) {
print $ftp->message;
}
$ftp->login( $Login, $Pwd );
print $ftp->message;
$ftp->cwd($ftpFolder);
@all_dir = $ftp->ls();
#print @all_dir;
foreach $ls_dir (@all_dir) {
if ( $ls_dir !~ /exe|txt|zip/ ) {
$latest_dir = $ls_dir;
}
}
print "$latest_dir\n";
$mcl_dir = '/daj/dhakj/ahdakl/abc_201206_def_05' . $latest_dir;
$ftp->cwd($mcl_dir) or die "not able to change the dir\n\n";
@zipFiles = grep /zip/, $ftp->dir;
foreach my $myfile (@zipFiles) {
if ( $myfile !~ /a|b|c|d|/g ) {
$ftp->get("$myfile");
print $ftp->message;
}
}
来源:https://stackoverflow.com/questions/9348978/why-am-i-getting-file-not-found-errors-with-this-perl-script-using-netftp