in reply to struggling with what should be a very simple perl task

my $href = { env4 => 20140830, env1 => 20140829, env2 => 20140828, env3 => 20140828, }; print "$_, $href->{$_}\n" for sort { $href->{$b} <=> $href->{$a} } key +s %$href;

If instead of a hash ref you have plain hash, it would change:

my %hash = ( ..... ); print "$_, $hash{$_}\n" for sort { $hash{$b} <=> $hash{$a} } keys %has +h;

But the hash construction you demonstrated in your example (despite missing commas) appeared to be the construction of a reference to an anonymous hash.


Dave

Replies are listed 'Best First'.
Re^2: struggling with what should be a very simple perl task
by Anonymous Monk on Aug 22, 2014 at 16:48 UTC
    that was way too easy! thank you, Dave!