## untested "idea" code ## package TwoWayHash; use overload '%{}' => \&as_hash; sub new { my $self = shift; my $hashref = shift; my %struct = ( 'data' => $hashref ); bless \%struct, $self; } sub as_hash { my $self = shift; # this will only work for simple hashes, really my $temp = reverse $self->{data}; return $temp{shift}; }