Thanks for all the replies. Here is the code that I have but still prints out the hashes unsorted? Not sure why?
foreach my $file ( $fns ) { open(FH, $file) or die "Can't open '$file': $!"; binmode(FH); my $hash = Digest::MD5->new->addfile(*FH)->hexdigest; $file_hashes{$hash} = $file; } foreach my $hash ( sort {$file_hashes{$a} cmp $file_hashes{$b} +} keys %file_hashes ) { print "$hash $file_hashes{$hash}\n"; } } ------------Results--------------- 32e3d09e0c2ff94316410b1444fbbb37a file1.txt 123d087078b62487c1d4c02f4c943af09 file2.txt 3ddbadc770e1c25a91aa186d3b0595945 file3.txt a3ff6417e3b703604c400965330ea6612 file4.txt b78c8fafdb9a5d4df6b36dcd35c56f6aa file5.txt

In reply to Re^2: Sorting an array of hashes and filenames by learningperl01
in thread Sorting an array of hashes and filenames by learningperl01

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.