in reply to Destructor() for a non OO script?

You can use an END block for this purpose. As long as you are just going to kill it with a CTRL+C this will work.

But be warned that if it terminates more abruptly, for instance someone does a kill -9 or you link to a C library that segfaults, the END block will never have a chance to run.

Update: Oops, ikegami is right. You do need to do more than just have an END block. My bad.

Replies are listed 'Best First'.
Re^2: Destructor() for a non OO script?
by ikegami (Patriarch) on Jan 21, 2009 at 04:51 UTC

    Not from what I can observe

    $ perl -le'END { print "END" } sleep();' ^C $

    Am I doing something wrong?