# GET FILE LIST if ( !$error_flag ) { if ( !$debug ) { @files = $ftp->list() or $error_flag = 1; $ftp->quit if $error_flag; } else { opendir( DIR, "$debug_ftp_directory/$directory_local" ) or $error_flag = 1; @files = readdir(DIR); closedir(DIR); } $report = $report . " ERROR: Can't get file list $!\n" if $error_flag; $error_cnt++ if $error_flag; } # GET ALL FILES (*.enc) TO LOCAL DIRECTORY, DELETE THEM ON SERVER foreach $file (@files) { if ( !$error_flag && $file =~ m/\.enc$/ ) { $report = $report . " Retrieving file $file\n"; if ( !$debug ) { $ftp->get($file) or $error_flag = 1; $ftp->quit if $error_flag; $ftp->delete($file) or $error_flag = 1; $ftp->quit if $error_flag; } else { move( "$debug_ftp_directory/$directory_local/$file", '.' ) or $error_flag = 1; } if ( !$error_flag ) { $downloaded_cnt++; } else { $report = $report . " ERROR: Can't retrieve file $file $!\n"; $error_cnt++; } } } if ( ( !$error_flag ) && ( !$debug ) ) { $ftp->quit; }