#!/usr/bin/perl use strict; my %hash = ( 'a' => '1', 'b' => '2', 'c' => '3', 'f' => '6', 'e' => '5', 'd' => '4' ); my $count = 0; foreach my $i ( sort keys %hash ) { print "$i ==> $hash{$i}\n" if ($count <= 4); $count++; }
In reply to Re: how to print top 5 elements from a hash
by bichonfrise74
in thread how to print top 5 elements from a hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |