use B; BEGIN { *CORE::GLOBAL::exec = sub { $_->object_2svref->() for B::end_av->ARRAY; CORE::exec @_; }; } END { print "last one\n" } END { print "I'm ending this right now!\n" } exec qw/ echo these arguments here /; __output__ I'm ending this right now! last one these arguments here