Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^2: die not exiting Application

by mihirjha (Novice)
on Apr 16, 2008 at 10:40 UTC ( #680763=note: print w/replies, xml ) Need Help??

in reply to Re: die not exiting Application
in thread die not exiting Application

I have noticed that the above problem is happening when we have TK error along with the open fail error in that case. TK:Error API get called instead of die_handler. Tk error are not considered fatal, so the application don't exit. But, this is not the right behavior of the application. Regards, Mihir

Replies are listed 'Best First'.
Re^3: die not exiting Application
by almut (Canon) on Apr 16, 2008 at 11:05 UTC

    In case die is overridden, you can call CORE::die instead.

    Update: maybe I should mention that this wouldn't help much, though, if the die should somehow happen to be trapped by an eval { ... } block  (which I don't know)...  In this case, you could try something along the lines of

    open my $fh, "<", $file or warn "Couldn't open '$file': $!" and ex +it;

    to force the program to terminate.

    Consider this

    my $file = "does-not-exist"; while (<STDIN>) { eval { open my $fh, "<", $file or warn "Couldn't open '$file': $!" and exit; }; print STDERR "ERROR: $@" if $@; }

    (which would actually terminate the program) vs.

    while (<STDIN>) { eval { open my $fh, "<", $file or CORE::die "Couldn't open '$file': $!"; }; print STDERR "ERROR: $@" if $@; }

    which would continue printing (despite the CORE::die)

    ERROR: Couldn't open 'does-not-exist': No such file or directory at ./ line 10, <STDIN> line 1. ERROR: Couldn't open 'does-not-exist': No such file or directory at ./ line 10, <STDIN> line 2. ...

    ...if you keep hitting the ENTER key.

    (If necessary, you could of course also use CORE::warn or CORE::exit in combination with the above...)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://680763]
[LanX]: line numbering is easy to fix with # line dircetives
[LanX]: I just wrote my first source filter, without changing the source
[LanX]: :)
[LanX]: Yesterday I made B::Concise produce a nested AoH of the optree instead of text
LanX chacka!!!
[LanX]: whats the correct way to make a perlbug report for perldoc?
[erix]: chacka

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2017-04-24 15:12 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (442 votes). Check out past polls.