in reply to Re^3: extract only smallest numbers
in thread extract only smallest numbers

Yes indeed. Or more concisely, just replace your 1 line:
$hash{$name} = $code;
With this single line instead:
$hash{$name} = $code if !defined $hash{$name} || $code < $hash{$name};
ie. You assign the latest value only if it's the first value for that key name, or if it's smaller than any previous value so far.

I'd recommend defined over exists in this case. If the hash key somehow did exist with an undefined value, the exists test would let it through, and then you'd then get a warning (under use warnings) when you got to the 'less than' comparison.

Using defined instead will avoid this potential banana skin, and give you the correct outcome.