Is this going in the right direction for you?
Sounds like you just need a HoA (Hash of Array).
#!/usr/bin/perl -w use strict; use Data::Dump qw(pp); my %h=( a=>123, b=>123, c=>12); print pp \%h; #{ a => 123, b => 123, c => 12 } print "\n"; # Access each key's value in the %h hash... # # Each "new key" in the reversed hash is a # unique value from the %h hash, i.e., $hash{$key} # # But each one of these new "keys" can contain # multiple values, so that means that the # reversed hash has to be a more complex data # structure, a hash of pointers to array... # # Each one of the keys of the "reversed hash" is # a value from the original hash. They now become keys # of that "reversed hash" and they have as a value, # a reference to an array of the keys of the original hash. my %reversed; foreach my $key (keys %h) { # the value of $h{$key} is the new key # could have been: # my $new_key = $h{$key}; # push @{$reversed{$new_key}}, $key; # but this is the same... push @{$reversed{$h{$key}}}, $key; } print pp \%reversed; #{ 12 => ["c"], 123 => ["a", "b"] } print "\n"; __END__ { a => 123, b => 123, c => 12 } { 12 => ["c"], 123 => ["a", "b"] }
Update: We are very far from needing MD5 keys. I am responding to your clarification of what you want for the output. Please respond to my post with other details if I didn't get it right...And I don't see that this has to do with maximum key length (which is pretty much unlimited).

In reply to Re^3: Maximum length of hash key ? by Marshall
in thread Maximum length of hash key ? by AlfaProject

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.