use Foo::Object; my %hash = (); &somesub; # does this garbage collect the object? delete $hash{'object'} if exists $hash{'object'} sub somesub { $hash{'object'}=new Foo::Object; }