use strict; use warnings; my %randLines; ++$randLines{1 + int rand 40_000_000} for 1 .. 20_000_000; my @hits = map {[$_, $randLines{$_}]} sort {$randLines{$b} <=> $randLines{$a}} keys %randLines; print scalar @hits, " different lines selected\n"; print "Line $_->[0] hit $_->[1] times\n" for @hits[0 .. 9];