I had a few spare moments, and tried using your code shotgunefx. You have a curly brace at the end of your second line and I assume you mean a paren.

Here's some test code to prove my point:
#!/usr/bin/perl use strict; use warnings; my %h1; my %h2; my %h3; for( my $count = 0, my $char = 'a'; $char ne 'aaaa'; $count++, $char++ + ) { # print "Adding $char with value of $count to h1\n"; $h1{ $char } = $count; } foreach my $key ( keys %h1) { $h2{ $key } = $h1{$key}; } foreach my $key (reverse sort keys %h1) { $h3{ $key } = $h1{$key}; } #foreach my $key (sort keys %h1) { print "h1: key: $key value: $h1{ +$key}\n";} #foreach my $key (sort keys %h2) { print "h2: key: $key value: $h2{ +$key}\n";} #foreach my $key (sort keys %h3) { print "h3: key: $key value: $h2{ +$key}\n";} my ($k1,$k2) = ( join('',sort keys %h1), join('',sort keys %h2) ); my ($k3,$k4) = ( join('',keys %h1), join('',keys %h2) ); my ($k5,$k6) = ( join('',sort keys %h1), join('',sort keys %h3) ); my ($k7,$k8) = ( join('',keys %h1), join('',keys %h3) ); print "inserted same order, keys sorted compare: " . ($k1 eq $k2 ? 1 : + 0) . "\n"; print "inserted same order, keys not sorted compare: " . ($k3 eq $k4 ? + 1 : 0) . "\n"; print "inserted reverse order, keys sorted compare: " . ($k5 eq $k6 ? +1 : 0) . "\n"; print "inserted reverse order, keys not sorted compare: " . ($k7 eq $k +8 ? 1 : 0) . "\n"; __DATA__ Prints: inserted same order, keys sorted compare: 1 inserted same order, keys not sorted compare: 0 inserted reverse order, keys sorted compare: 1 inserted reverse order, keys not sorted compare: 0
So to answer your question about sorting, the sort of the keys is necessary or the compare will not work.

In reply to Re: Re: Comparing all keys in a hash by Helter
in thread Comparing all keys in a hash by rinceWind

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.