in reply to Re: Perl dbi disconnect question...
in thread Perl dbi disconnect question...

Thanks, Zaxo!

I'm using bail_out to print a host of other messages, some for a successful executing of a query or process. Should I then have exit(0) or exit(1)?

  • Comment on Re: Re: Perl dbi disconnect question...

Replies are listed 'Best First'.
Re: Re: Re: Perl dbi disconnect question...
by Zaxo (Archbishop) on Jan 05, 2004 at 01:16 UTC

    I think you should refactor so that you handle errors with one functions and success with another. Reserve exit(0) for leaving with your utility having done everything your user should expect. You may want to give exit different values to represent differeent errors. 0+$! is a good value if the reason is an error that sets $!. Or you could call die $!, instead.

    After Compline,
    Zaxo

      Ah, I see. So I should have a different bail out sub when an error occurs during a query execution. Will the following do?

      sub bail_out2 { my $message = shift # output error in html # exit with 1 because it's a failure exit(1); }
      Does exiting with the value of 1 automatically kills the database connection?

      I need to print out the error in html to let the user know that something has gone wrong with the processing of the script. die prints the error to the log which is invisible to the user. Am I right?