http://qs321.pair.com?node_id=11137269


in reply to Re: CGI::Carp fatalsToFile
in thread CGI::Carp fatalsToFile

Thanks for the very helpful reply

You could try putting this at the top of the script:
use CGI::Carp qw(set_die_handler); BEGIN { sub handle_errors { my $msg = shift; print "Content-Type: text/html\n\n"; print "$msg"; } set_die_handler(\&handle_errors); }

I'm going to write some test code so that I can properly test what is going on. It will probably have to wait until the weekend though. But this code has been a little confused!

Is set_die_handler a method of CGI::Carp and set_die_handler(\&handle_errors); in the BEGIN block is overriding it?
Or is something different happening here?

Replies are listed 'Best First'.
Re^3: CGI::Carp fatalsToFile
by tangent (Vicar) on Oct 06, 2021 at 17:34 UTC
    Is set_die_handler a method of CGI::Carp and set_die_handler(\&handle_errors); in the BEGIN block is overriding it?

    set_die_handler is a method of CGI::Carp, but its purpose is to allow you to specify your own function to be executed "any time a script calls "die", has a syntax error, or dies unexpectedly at runtime". See the docs for more.