in reply to printing largest hash value
#!/usr/bin/perl my %hash = ( red => 2, pink => 1, orange => 4, black => 3, blue => 4 ); foreach ( reverse sort { $b <=> $a } keys %hash ) { if ( !$highest || $hash{$_} == $highest ) { print "\t$_, $hash{$_}\n"; $highest = $hash{$_}; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: printing largest hash value
by tomhukins (Curate) on Feb 22, 2005 at 09:40 UTC |