- or download this
use strict;
...
my @top_ten = @array[0..9];
print "$_\n" for @top_ten;
- or download this
# ... original code
for ((sort { $counted{$b} <=> $counted{$a} } keys %counted)[0..2]) {
# ... etc.
}
- or download this
# pick one:
my $max = 2; # use [0..$max]
my $max = 3; # use [1..$max] or [0..$max-1]