I'm writing a script that'll read through my ftpd logs and generate a hash as follows:
$stats = \{
'user1' => {
'files' => 281,
'size' => '3724251021'
},
'user2' => {
'files' => 555,
'size' => '7385856997'
},
'user3' => {
'files' => 235,
'size' => '3716904486'
},
'user4' => {
'files' => 578,
'size' => '8536026929'
}
};
How do I access this hash with the keys sorted by size?
I tried this but I get an error saying not a hashref
foreach my $user (sort { $$stats->{$a}->{size} cmp $$stats->{$b}->{size} } keys %$stats) {
blahblahblah...
}