Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by kbrint (Sexton)
on Dec 02, 2005 at 08:47 UTC ( #513535=note: print w/ replies, xml ) Need Help??


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

my (@items, @unique, %seen); for (@items) { push @unique, $_ unless $seen{$_}++; }
This has a few benefits:
  • Deterministic ordering.
  • Works for objects and passes them through to @unique without stringification.


Comment on Re: To Hash or to Array--Uniqueness is the question.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://513535]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2014-09-20 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (157 votes), past polls