in reply to removing doubles by comparing two strings - newbie question!

This kind of problem cries out (in my mind, at least) for the use of a hash (associative array). I generally load up a common hash with the values of one list, and then step through the second list doing the same. The resulting hash will have one entry for each unique key, since hashes resolve collisions in that way.

Similar problems like finding the intersection between two sets, or getting the complement of the intersection, can be handled in like manner, by incrementing the value of the hash or deleting hash entries on a match.

Of course, there's more than one way to do it. :)

Update: Ah, I see [id://Tanktalus] has already hinted in this direction. Darn those 'Johnny-on-the-spot' Monks!

See also the timely Re: How can I assign the elements in an array to only the key values in a hash?, which bears on your problem.


No good deed goes unpunished. -- (attributed to) Oscar Wilde
  • Comment on Re: removing doubles by comparing two strings - newbie question!