http://www.perlmonks.org?node_id=982387


in reply to Reference to guard not released

I can't explain what is happening, but I can offer work around :)

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