Here is one algorithm:
- Read file 1 using open
- Read each line using while
- split each line on whitespace in to Name and Number variables
- Store those variables in a hash with Name as the key and Number as the value
- close file 1
- Read file 2
- split each line into a new array
- compare each item of the new array with each key of the hash, incrementing a counter each time there is a match
- print the number of matches for the line
- close file 2
This may not be the most efficient algorithm, but you can try it, then post your code; you are sure to get constructive criticism on code that you post.