Please provide exact error messages, as you don't tell us which line of your example code the error happens (How do I post a question effectively?). I can only make a guess:
$ftp->get($file) or $error_flag = 1; $ftp->quit if $error_flag; $ftp->delete($file) or $error_flag = 1; $ftp->quit if $error_flag;
This logic says that if $ftp->get($file) returns a false value, to call $ftp->quit, and then call $ftp->delete($file), even though by then the connection might be closed. Also, although apparently not related to your error message:
opendir( DIR, "$debug_ftp_directory/$directory_local" ) or $error_flag = 1; @files = readdir(DIR); closedir(DIR);
That's not quite right as it will attempt to readdir and closedir even if the opendir fails. It's usually better to opendir ... or die ... and handle the error elsewhere.
In general, you seem to be relying quite heavily on $error_flag to control the flow of your program, which leads to lots of repeated statements (if ( !$error_flag ... and $ftp->quit) and logic that can easily break if you later insert more statements into the code. I would suggest you look into flow control statements like last and next, as well as breaking your code down into subroutines from which you can return. Even dieing or croaking combined with Try::Tiny (or similar) is a good method for exception handling - for example, you could place your error counting/reporting into a catch block, $ftp->quit into a finally block, and then just die from the main code in the try block in case of errors.
In reply to Re: FTPSSL Bad file number
by Anonymous Monk
in thread FTPSSL Bad file number
by Bettan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |