in reply to get a key for a value revisited

It sounds like you want to organize your data as a Hash-of-Arrays structure, which can support multiple values for each key. To retrieve a key corresponding to a value, you could loop through the keys of the hash, then loop through the array elements for each key:
use strict; use warnings; use Data::Dumper; # %data is an example Hash-of-Arrays structure # where the hash has 3 keys (a,b,c) and each # key has 3 values: my %data = ( a => [1..3], b => [4..6], c => [7..9], ); #print Dumper(\%data); print get_key(3), "\n"; print get_key(8), "\n"; print get_key(0), "\n"; sub get_key { my $value = shift; for my $key (keys %data) { for my $val (@{ $data{$key} }) { if ($val eq $value) { return $key; } } } return 'key not found'; } __END__ a c key not found