local $SIG{KILL} = \&killed; ### some code sub killed { print "I got killed\n"; } #### END { print "I got killed! \n "; }