Help for this page

Select Code to Download


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