in reply to Perl, Die, and IIS

You could write your own version of die:

sub my_die { open(my $fh, ">>", $dieFile); print $fh @_; exit(2); # or die("\n"); # or die(@_); } my $value = somecommand or my_die "$!\n";

Alternatively, you could try hooking $SIG{'__DIE__'}. It's documented in perlvar, under %SIG.

Replies are listed 'Best First'.
Re^2: Perl, Die, and IIS
by Aristotle (Chancellor) on Nov 14, 2005 at 21:42 UTC

    Don’t use stuff like my_die, which will not be respected by loaded modules. Don’t roll your own die handler.

    Do use CGI::Carp. In development, the easiest thing to do is use CGI::Carp qw( fatalsToBrowser );. Once you are in production on an errorlog-challenged server, you do what the module’s POD says:

    BEGIN { use CGI::Carp qw( carpout ); my $logfile = '/path/to/cgi-name.log'; open my $logfh, '>>', $logfile or die "Unable to open $logfile: $!\n"; carpout $logfh; }

    Makeshifts last the longest.