use strict; use Scope::Guard; my $x; { my $g = Scope::Guard->new(sub {$x; warn "destroyed"}); } warn "end";