http://www.perlmonks.org?node_id=260554


in reply to Unique testing problem

... but, since the code calls exit(0); it never returns to the test program

So you better go along the lines of BazB's suggestion, as an exit would kill your mod_perl on a webserver. No need to fumble with exit here. Just just die and return reasonable stuff. See SIGDIE by Adam for an elaboration on that.

Have a nice day
All decision is left to your taste

Update
No need to have your own __DIE__ handler, just die for a good reason die "action failed .. some more elusive stuff" and the place where you call it should be able to interpet those comments on proper death. *smile*
keep it simple

Replies are listed 'Best First'.
Re^2: Unique testing problem
by adrianh (Chancellor) on May 24, 2003 at 11:19 UTC
    So you better go along the lines of BazB's suggestion, as an exit would kill your mod_perl on a webserver

    Nobody's mentioned mod_perl :-)

    Also, since perl 5.6, mod_perl overrides exit behind the scenes so it's often a non-issue.

    No need to fumble with exit here. Just just die and return reasonable stuff. See SIGDIE by Adam for an elaboration on that.

    I would not recommend using a __DIE__ handler in mod_perl code. It's global nature causes problems if you need to support multiple applications, virtual hosts, etc.

    Alternative Exception Handling Techniques in the mod_perl guide has more info on this.

    Personally, if there was the opportunity, I would probably try to refactor the code so that there were not multiple exit points for the program, rather than throwing exceptions into the mix. Multiple exit points are a Code Smell in my experience.