misterperl has asked for the wisdom of the Perl Monks concerning the following question:

After a successful file transfer, I issued a $ftph->quit , in the debugger. I immediately got a "Debugged program terminated" with no unusual warnings or errors, even though there are many more lines to execute after this statement.

Is quit supposed to also terminate execution? Is there anther module I should call to disconnect and end the session?

To be clear- I was expecting quit to just terminate the ftp connection and end the session, not script execution, as the Net::FTP docs say they should.

Replies are listed 'Best First'.
Re: Net::FTP quit terminates Perl script
by hippo (Archbishop) on Jul 15, 2015 at 16:51 UTC

    The quit method does not exit the script for me. Simple test:

    #!/usr/bin/perl use strict; use warnings; use Net::FTP; my $ftp = Net::FTP->new ('ftp.perl.org'); $ftp->login ('anonymous'); print $ftp->pwd (); $ftp->quit; print "And now an extra line.\n";

    which results in the expected output:

    /And now an extra line.

    That's with version 2.77 of Net::FTP.

      I ran your testcase in and out of the debugger and you're correct- I have the same result.

      In my case there must be something else going on, because I get this:

      DB<6> l 281==>b closedir DIR; 282: $ftph->quit(); 283 284: open STDERR, ">&OLD_STDERR"; 285 286: $result->{status} = 0; 287: return $result;
      and when I press n 2 times...
      DB<6> n genericFTP::ftpFiles(/var/www/cgi-bin/orderform/genericFTP.pm:282): 282: $ftph->quit(); DB<6> n Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info.
        Turned out that $ftph had gone out of scope and was undef. But instead of telling me that, Perl decided to go to

        CGI::DESTROY

        for some reason, which quickly lead to an exit without reporting anything. and use strict and warning didn't throw anything.

        Once I fixed the scope everything was fine. What an odd way to (NOT) report the object was undef!? If Perl had simply said object $ftph not defined, it would have been a 1 second fix.

        Thanks for your tip I voted you ++

Re: Net::FTP quit terminates Perl script
by Anonymous Monk on Jul 15, 2015 at 17:27 UTC

    My guess is you're being hit with SIGPIPE. Try catching the signal.