Have you even taken a look at the advise given in your other node (Multiple Hash key values problem !!)? Specifically, the replies from gwadej and repellent.
This code only requires a couple of small changes.
Instead of $href{$1} = $2 if $_ =~ /(\S+)\s+(\S+)/;, you need to use a hash of arrays and push the new value into the array ref associated with that key.
Your second while loop is going to need a nested loop within. After splitting the numbers, loop over each number in @{$href{$name}} and check for the condition.
Trying out these suggestions, as well as those given by others in your other post should get you to where you need to be.