Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

END blocks in perl

by clueless newbie (Hermit)
on Oct 16, 2007 at 14:05 UTC ( #645178=perlquestion: print w/ replies, xml ) Need Help??
clueless newbie has asked for the wisdom of the Perl Monks concerning the following question:

The issue has come up as to the reliability of perl's END block. Excluding hardware failure, what will prevent the END block from executing?

Comment on END blocks in perl
Re: END blocks in perl
by Sidhekin (Priest) on Oct 16, 2007 at 14:32 UTC

    what will prevent the END block from executing?

    exec, for starters:

    perl -le 'END { print "Can you hear me?" } exec $^X, -le => exit => 0'

    Also, internal errors (segfaults, core dumps, whatever):

    perl -le 'END { print "Can you hear me?" } dump'

    So don't rely on it too much.

    print "Just another Perl ${\(trickster and hacker)},"
    The Sidhekin proves Sidhe did it!

Re: END blocks in perl
by toolic (Chancellor) on Oct 16, 2007 at 14:48 UTC
      Can this be used to catch the seg faults and some of the whatevers that Sid has mentioned?
        You don't want a program that segfaults to continue. It tries to mess up the memory of your computer, and you should be glad it is not allowed to do so. A program which crosses its borders in that way should be examined and debugged immediately; it's not that kind of errors you can lightly sweep under the rug.

        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: END blocks in perl
by adrianh (Chancellor) on Oct 18, 2007 at 12:59 UTC

    In addition to those methods already mentioned, POSIX::_exit() will not run END blocks.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://645178]
Approved by polettix
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-12-27 23:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls