in reply to re-useing a hash

It looks like you want a lexical variable. Use my() to make the variable private to the block. With each iteration, you get a different hash (and at the end, throw the current on away).

foreach $uniqu ( ... ){ my %hash; ...

However, what you have now should be clearing out the hash. Setting it to the empty list shouldn't leave anything in it. There might be something else going on if you are seeing odd results.

Good luck!

brian d foy <>