156 $ftp->get($file) or $e +rror_flag = 1; 157 $ftp->quit() if $error +_flag; 158 $ftp->delete($file) or + $error_flag = 1; 159 $ftp->quit() if $error +_flag;

What happens when $ftp->get($file) in line 156 fails?

  1. $error_flag is set in the same line
  2. $ftp->quit() is called, in line 157. Tthis will close the FTP connection.
  3. $ftp->delete() is called, in line 158. This will fail, because the FTP connection in $ftp is closed.
  4. $error_flag is set again, in line 158.
  5. $ftp->quit() is called again, in line 159. This will fail again, because the FTP connectin in $ftp is still closed.

I don't think this is what you really want. You want to abort when $ftp->get($file) fails. Why don't you use die and eval {...} instead of fiddling with error flags? Or at least break out of the foreach loop using last?

Anonymous Monk explained this problem in the first reply, but it seems you ignored it or did not understand it.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^5: FTPSSL Bad file number by afoken
in thread FTPSSL Bad file number by Bettan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.