in reply to Re: max "value " of an hash
in thread max "value " of an hash
Of course, List::Util also comes with max() and maxstr():
#!perl use 5.010; use strict; use warnings; no warnings 'numeric'; # otherwise max() gives a warning on keys "a" and "b" my %hash = (a => 'value' , b => 'value', 0 => 'value', 1 => 'value'); # the values don't matter for this example use List::Util (qw/max maxstr/); my $max = max (keys %hash); my $maxstr = maxstr (keys %hash); say "numeric: $max\tstring: $maxstr";
returns
numeric: 1 string: b
|
|---|