in reply to undef-ing an active subroutine

Along with the lovely suggestions from ikegami and moritz, you can use caller to make the deletion less fragile if you move your subroutine about:

#!/usr/bin/perl use strict; use warnings; foo(); eval{foo()} or warn $@; print "Done\n"; sub foo { { no strict 'refs'; undef *{(caller(0))[3]}; } print "foo was called\n"; }