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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |