As you can see, you have to beware of the return value for your log function, otherwise it will happily turn an error into something good. You could use some exception handling here:#!/usr/bin/perl use strict; use warnings; sub fails { 0 } sub logs { print "error!\n"; 1 } (fails or logs) and print "all ok so far...\n"; __END__ ~/sviluppo/perl> perl example.pl error! all ok so far...
#!/usr/bin/perl use strict; use warnings; sub fails { 0 } sub logs { print "error: @_"; 1 } eval { 1 or die "some message here for first part"; fails or die "some message here for second part"; }; if ($@) { logs($@); exit 1; # i.e. return failure } # Otherwise all ok... __END__ ~/sviluppo/perl> perl example.pl error: some message here for second part at example.pl line 11.
Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')
Don't fool yourself.In reply to Re^3: Net::FTP not catching errors, my fault?
by polettix
in thread [solved] Net::FTP not catching errors, my fault?
by ryanc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |