http://www.perlmonks.org?node_id=513526


in reply to To Hash or to Array--Uniqueness is the question.

Using a hash for uniqueness is the canonical means of maintaining a unique set with Perl. However, the 'values' needn't be "arbitrary". There are all sorts of uses for the values, such as:

Your second option, "Use an array; filtering it through a routine that makes it unique" is probably going to still employ a hash as the means of filtering. The array simply would keep the entries in some specific order. But as mentioned above, you can keep track of order by simply using the filter hash's values.


Dave

  • Comment on Re: To Hash or to Array--Uniqueness is the question.