my %matches; while (my ($key,$value) = each %somehash) { # stringified arrays as keys push @{$matches{stringify([sort @$value])}} => $key; }