in reply to for loop trouble
I guess your problem may be that you put all pids in @potential_hgt whenever it doesn't match an $orth. Is it possible that you wanted to put there only those that don't match any of the @orthologs?