in reply to Sorting an array of hashes and filenames
I'm think you need to change your code something like that:
my @hashes; foreach my $filename (@filenames) { open my $fh, "<", $filename or die "Can't open $filename: $!"; binmode $fh; push @hashes, [ Digest::MD5->new->addfile($fh)->hexdigest, $filename + ]; close $fh; } my @sorted = sort { $a->[0] cmp $b->[0] } @hashes; print "$sorted[0] $sorted[1]\n";
Update: Fixed error with array vs. arrayref (thanks to oshalla).
|
|---|