I
IanW
I have a hash arrangement that is used to store data like this:
$hash{directory}{filename}{size}
I want to sort the files in a directory by size before listing them. I
thought I could do it like this ($dir contains the current directory):
foreach my $f (sort { $filehash{$dir}{$a}{size} <=>
$filehash{$dir}{$b}{size} } keys %{ $filehash{$dir} }) { }
However that doesn't seem to work.. I have to confess to still not having
got my head round data structures in Perl, so it may be something obvious
but please put me out of my misery anyway.
Thanks
Ian
$hash{directory}{filename}{size}
I want to sort the files in a directory by size before listing them. I
thought I could do it like this ($dir contains the current directory):
foreach my $f (sort { $filehash{$dir}{$a}{size} <=>
$filehash{$dir}{$b}{size} } keys %{ $filehash{$dir} }) { }
However that doesn't seem to work.. I have to confess to still not having
got my head round data structures in Perl, so it may be something obvious
but please put me out of my misery anyway.
Thanks
Ian