use strict; use warnings; package testhiding; sub new { bless [], shift; } { my %foo = (); my %bar = (); sub foo { my $self = shift; my $new = shift; my $old = $foo{$self}; $foo{$self} = $new if defined($new); $old; } sub bar { my $self = shift; my $new = shift; my $old = $bar{$self}; $bar{$self} = $new if defined($new); $old; } sub DESTROY { my $self = shift; delete $_->{$self} for (\%foo, \%bar); } } 1;