in reply to Re^2: print the values
in thread print the values

Don't push them into @names if they already exist in %names_hash; add a conditional to the line with the push.