http://www.perlmonks.org?node_id=689639


in reply to What is safe to do in an END block?

I worked on a system to send alerts when servers suffered difficulties. The system had to be fault-tolerant as possible, so I used the END block to record some state information in a flat file and execute a system command to sendmail (or whatever mail sender was installed) to send any pending alerts along with a message indicating abnormal termination as a result of a die() or anything else out of the ordinary. The script also tried to restart itself on exit.

It seemed to work as intended, and if you have any reservations about Perl's ability to perform complex operations in the end block, committing some state information to a flat file may be a good Plan B.

  • Comment on Re: What is safe to do in an END block?