in reply to Re^2: (almost) Unique elements of an array
in thread (almost) Unique elements of an array

That's brilliant - excellent to know about the fact it's better to go to uppercase to do this too - thanks.

It leaves me wondering if there is any reason to use a hash to store a big list of words over an array and is it possible or sensible to turn %uniq into @uniq.

  • Comment on Re^3: (almost) Unique elements of an array

Replies are listed 'Best First'.
Re^4: (almost) Unique elements of an array
by tlm (Prior) on Jul 14, 2005 at 15:03 UTC

    The hash is just a trick to enforce uniqueness, since, by definition, hashkeys are unique (any attempt to "duplicate" a hashkey at most changes the value that the key is associated with, but no duplicate is created).

    If you want the array you can do

    my @uniq = keys %{ +{ map +( uc() => undef ), @ar } };

    the lowliest monk