Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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 ./ +680735.pl line 10, <STDIN> line 1. ERROR: Couldn't open 'does-not-exist': No such file or directory at ./ +680735.pl 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...)


In reply to Re^3: die not exiting Application by almut
in thread die not exiting Application by mihirjha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-23 20:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found