... 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