in reply to Hash Question

The problem is that you are updating your hash every time you see a new line. You need to update the hash conditionally on whether you've already seen the data you're interested in. Try changing your line:

acct{$x} = ($x,$line);

To:

$acct{$x} = ($x,$line) unless exists $acct{$x}

This way you only update your hash if you've never seen the account number before.