Your code makes sense: you add an x to a name if it already exists, making it unique. This may lead to names with endless rows of x's (in theory, in the real world there will not be much more than 2 or 3) but still unique because of them. It's a very simple workaround and I like it! In the end, I don't want the x's to turn up in my alignmentfiles but I can easily remove them later.
Thanks!
Comment on Re^2: [BioPerl] add_seq gives warning: why?
Probbaly a better workaround, might be to use the full name (including the position info) as the id, rather than what is currently happening. Presumably there can't be sequences with the same base name and position? This way you don't have to worry about taking x's off etc...