A victim object with a destructor can be your instructor.
package Canary; sub new { return bless {}, shift(); } sub DESTROY { warn "*CHEEP* *GASP*"; } package main; END { warn "END BLOCK\n"; } $| = 1; my $closure; { my $boid = Canary->new(); $closure = sub { $boid = $boid; warn "Fweee\n"; }; } $closure->(); warn "Pre undef\n"; undef $closure; warn "Post undef\n"; exit 0; __END__ $ perl spoozle Fweee Pre undef *CHEEP* *GASP* at spoozle line 4. Post undef END BLOCK
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re: When are references within a closure freed?
by Fletch
in thread When are references within a closure freed?
by Socrates
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |