Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Is there an easy way to assign guaranteed unique values to a simple array without looping through whole array?

by mreece (Friar)
on Nov 30, 2007 at 02:26 UTC ( [id://654029]=note: print w/replies, xml ) Need Help??


in reply to Is there an easy way to assign guaranteed unique values to a simple array without looping through whole array?

if i understand correctly, you can do it with an intermediate hash and grep.
my %seen; my @nodupes = grep { not $seen{$_}++ } @mayhavedupes;
as for whether you consider grep "having to loop" or not, well, it's a lot less loopy than sorting keys...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-03-28 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found