Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by CountZero (Bishop)
on Dec 02, 2005 at 09:02 UTC ( #513537=note: print w/replies, xml ) Need Help??


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

Never invent the wheel again: use the List::MoreUtils module which has a uniq-function.
uniq LIST

Returns a new list by stripping duplicate values in LIST. The order of elements in the returned list is the same as in LIST. In scalar context, returns the number of unique elements in LIST.

my @x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 my $x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://513537]
help
Chatterbox?
[talexb]: Does the mis-spelled title "SSL Apgrade failed" bug anyone else? Wish the authour would fix it. This is the node I'm talking about.

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2017-07-25 17:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (376 votes). Check out past polls.