sub DESTROY { my ($self) = @_; my $id = ID($self); push @_, $id; print "here we are in DESTROY\n"; DEMOLISH: for my $base_class (_hierarchy_of(ref $_[0])) { no strict 'refs'; print "destroying $base_class\n"; # no warnings 'once'; if (my $demolish_ref = *{$base_class.'::DEMOLISH'}{CODE}) { print "about to call destroy on $base_class\n"; &{$demolish_ref}; } for my $attr_ref ( @{$attribute{$base_class}} ) { delete $attr_ref->{ref}{$id}; } } }