Code Comments
Programming Forum and web based access to our favorite programming groups.Does die call exit when it's excuted?
If so,when I overwrote exit() function in my script,would die call this cust
omized exit?
I gave a test,but didn't see die calling exit distinctly.
This works as I wanted:
use strict;
use warnings;
sub exit {
print "test exit";
exit;
}
&exit;
But this won't:
use strict;
use warnings;
sub exit {
print "test exit";
exit;
}
die;
Glad to hear any words from you.
--
Jeff Pang <pangj@earthlink.net>
http://home.arcor.de/jeffpang/
Post Follow-up to this messageJeff Pang wrote:
> Does die call exit when it's excuted?
> If so,when I overwrote exit() function in my script,would die call this cu
stomized 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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.