in reply to Net::FTP quit terminates Perl script

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.

Replies are listed 'Best First'.
Re^2: Net::FTP quit terminates Perl script
by misterperl (Friar) on Jul 15, 2015 at 17:02 UTC
    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 ++