Help for this page

Select Code to Download


  1. or download this
    my %hash_name = (a => 1, b => 2, c => 3);
    my $max = (keys %hash_name)[0];
    $hash_name{$_} > $hash_name{$max} and $max = $_ for keys %hash_name;
    print $max;
    
  2. or download this
    use List::UtilsBy qw{ max_by };
    
    my %hash_name = (a => 1, b => 2, c => 3);
    my $max = max_by { $hash_name{$_} } keys %hash_name;
    print $max;