in reply to compare values within a hash

I think you should clarify your spec. Are you only comparing numbers within a group, or also between groups? If the former, maybe a hash-of-arrays might be a suitable approach. This assumes that your input file is not huge, and you can read it into memory all at once.

Each hash key could be a group name: group1, group2, etc. You would push 2-element arrays for each group. Once you have everything read in, you could loop through the keys, perform your comparisons on each array by 1st element, then by 2nd element, if necessary.