You can gain a tad more by truncating the 64-bit int to 6 bytes, but you're into a world of diminishing returns:

#! perl -slw use strict; #use Math::Random::MT qw[ rand ]; use Devel::Size qw[ total_size ]; our $S //= 1; srand( $S ); my %hash; for( 1 .. 1e6 ) { my( $x, $y, $z ) = ( int( rand 20 ), int( rand 1.2e6 ), int( rand +1.2e6 ) ); # ++$hash{ $x }{ $y }{ $z }; # ++$hash{ join $;, $x, $y, $z }; # ++$hash{ pack 'Q', $x * 1.2e6**2 + $y * 1.2e6 + $z }; ++$hash{ unpack 'A6', pack 'Q', $x * 1.2e6**2 + $y * 1.2e6 + $z }; } print total_size( \%hash ), ' ', scalar keys %hash; __END__ ++$hash{ $x }{ $y }{ $z }; + 269 897 378 ++$hash{ join $;, $x, $y, $z }; + 106 036 953 40% ++$hash{ pack 'Q', $x * 1.2e6**2 + $y * 1.2e6 + $z }; + 98 388 672 36.5% ++$hash{ unpack 'A6', pack 'Q', $x * 1.2e6**2 + $y * 1.2e6 + $z }; + 96 193 539 35.6%

Beyond that, if it is still a problem, print the triplets to stdout and pipe the results through your system sort and then into a another perl script that counts them:

C:\test>perl -E"say join ' ', int( rand 20 ), sort{ $a<=>$b } int( ran +d 1.2e6 ), int( rand 1.2e6 ) for 1 .. 1e6" | sort | perl -nle"if($last eq $_){ ++$n }else{ print qq[$last : $n];$n=1} $l +ast=$_" | wc -l 999978

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice. Not understood.

In reply to Re^5: Tallying co-occurence of numbers by BrowserUk
in thread Tallying co-occurence of numbers by K_Edw

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.