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; #### use strict; use warnings; package testhiding; sub new { bless [], shift; } { my %foo = (); sub foo { my $self = shift; my $new = shift; my $old = $foo{$self}; $foo{$self} = $new if defined($new); $old; } } { my %bar = (); sub bar { my $self = shift; my $new = shift; my $old = $bar{$self}; $bar{$self} = $new if defined($new); $old; } } # XXX - Where does this go then... sub DESTROY { my $self = shift; delete $_->{$self} for (\%foo, \%bar); } 1;