my $n = 3; # top three my @highest = (sort { $b <=> $a } @num)[0 .. $n-1];