The $ref was added at my suggestion as the keys in file 1 are not unique, so an array is needed to store the varying $pos values that $key can have. The suggested code produced exactly the result requested in the "Multiple Key Problem Help" thread.
I agree with the rest of your response. Way too many threads for some very basic problems. A bit of googling would answer the problem raised this time.