my %drink; # other attribute hashes sub set { my ($key, $attr, $value) = @_; my $hashref; eval "\$hashref = \\\%$attr"; if ( !defined $hashref ) { carp 'Invalid attribute name'; } else { $hashref->{$key} = $value; } }