Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

die and exit
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/

Report this thread to moderator Post Follow-up to this message
Old Post
Jeff Pang
08-14-07 02:55 AM


Re: die and exit
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 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

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
08-15-07 11:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL CGI Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:04 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.