Subject: | memory leak (DESTROY is useless as you have it) |
Heres one which won't leak memory,
of course you still have to actually invoke ->DESTROY
because of the circular refs, undef $tree won't work
(you can remedy that with Scalar::Util's weaken).
sub DESTROY {
my ($self) = @_;
local $_;
# sub isLeaf should probably make sure _children is not undef
unless( $self->{_children} and $self->isLeaf()){
defined $_
and $_->DESTROY()
for @{$self->{_children}};
}
delete $self->{$_} for keys %$self;
return;
}