in reply to Re: Who's referencing my variables?
in thread Who's referencing my variables?
When you run this, "bye bye" is not printed while we're waiting inside ETERNITY because @Foo::objects still holds a reference to $foo, even though its instantiation happened inside a scope we've since left.package Foo; my @objects; sub new { my $self = bless {}, shift; push @objects, $self; return $self; } sub DESTROY { print "bye bye" } package main; { my $foo = Foo->new; } ETERNITY: while(1) { # DESTROY is NOT called yet. }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Who's referencing my variables?
by AnomalousMonk (Archbishop) on Apr 01, 2014 at 16:24 UTC | |
|
Re^3: Who's referencing my variables?
by Anonymous Monk on Apr 01, 2014 at 12:51 UTC | |
by Anonymous Monk on Apr 01, 2014 at 14:41 UTC | |
by Anonymous Monk on Apr 01, 2014 at 15:10 UTC |