I updated my post
Re: Help with function, count matches and store in hash & retrieve sorted, is that helpful to you?
Well, after looking yet again, I am still not sure. Can you give use the exact inputs that you are using so that we can run and exactly replicate your error with your data?
I am a bit puzzled about how you can get an undef value for $max_count? Which is assigned to the key "max". Of course:
my $element;
$element->{bar} = $key;
$element->{max} = $max_count;
$element->{max} //= 0; #### adding this prevents undef
push @match_count, $element;
I guess I have the Sunday brain cramp.