package Test; my %attr; sub new {bless [] => shift} sub init {$attr {+shift} = undef} sub attr { my $self = shift; $attr {$self} = shift if @_; $attr {$self} } sub DESTROY { delete $attr {+shift} } sub HowMany {scalar keys %attr}