use strict; use warnings; use Hash::Util::FieldHash; fieldhash my %attr1; # You need one for each attribute. sub new {bless \do {my $var}, shift} sub set_attr1 { my $self = shift; $attr1{$self} = shift; } sub get_attr1 { my $self = shift; $attr1{$self} } etc.