in reply to Re^2: How to add missing part in a Hash of Array
in thread How to add missing part in a Hash of Array
Or, if your data is small, you could possibly even use the sort function to do it in one single instruction:my ($min, $max) = (1e10, -1e10); for my $value (keys %hash) { $min = $value if $value < $min; $max = $value if $value > $max; } # $now $min has the smallest key and $max the highest one
But that's getting quickly rather inefficient when the data is growing.my ($min, $max) = (sort {$a<=>$b} keys %hash)[0,-1];
|
|---|