in reply to Checking Hash contents

You have a space between "$values" and "{$key}" in your print statement that use strict would have caught. Once that is fixed, since the foreach...print loop is inside the while loop, you will be reprinting an ever increasing number of hash values for every value you read in. So move the foreach loop outside of the while loop. And this can not be a complete program, since you open neither INFILE nor OUTPUT...it would have been better if you posted a (small, but) complete example.

Note: the OP is a duplicate of a node in this thread.