package SillyClass; require Tie::Hash; @ISA = (Tie::Hash); sub new { my $proto = shift; my $class = ref ($proto) || $proto; my $this = bless { }, $class; tie %{$this}, $class; return $this; } sub TIEHASH { my $self = shift; my $node = { color => 'blue', age => 12, pet => 'dog', }; return bless $node, $self; } sub DESTROY { my $self = shift; print "Calling DESTROY by $self\n"; } #------end class definition------ package main; my $fred = SillyClass->new(); undef $fred; ## DESTROY gets called twice, once by "$fred" and by "tied $fred"