Jeff Pang wrote:
Does die call exit when it's excuted?
If so,when I overwrote exit() function in my script,would die call this 
customized exit?

I gave a test,but didn't see die calling exit distinctly.

Neither did I.

But you can override die() directly.

    sub die {
        print "test die\n";
        CORE::die;
    }

and call it as

    ¨

or

    main::die;

or, probably better:

    use subs 'die';

    sub die {
        print "test die\n";
        CORE::die;
    }

    die;

Finally, this is another technique for overriding a built-in function:

    BEGIN {
        *CORE::GLOBAL::die = sub {
            print "test die\n";
            CORE::die;
        };
    }

    die;

The latter one also affects calls for die() from use()d and require()d modules.

HOWEVER, since you asked on a CGI list, I suspect that you really don't need to use any of the above methods. To have die messages appear in the browser you'd better do:

    use CGI::Carp 'fatalsToBrowser';

    die "test die";

HTH

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


  • die and exit Jeff Pang
    • Re: die and exit Gunnar Hjalmarsson

Reply via email to