$main::SIG{__DIE__} = \&some_function; # when does this get run? #### #!/usr/bin/perl use strict; use warnings; use feature qw/say/; sub function { say "Howdy!"; } #die "horribly"; $main::SIG{__DIE__} = \&function; #die "horribly"; #BEGIN { die "horribly"; }