Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Removing duplicates from an array

by gasho (Beadle)
on Jan 02, 2008 at 18:09 UTC ( [id://660022]=note: print w/replies, xml ) Need Help??


in reply to Removing duplicates from an array

###################################################################### +####### # Remove duplicated array members # For example if you have an array @D=qw(1 2 1 3 1 4 1 5) # It will return an array [1 2 3 4 5] # Usage @Clean=nonDuplicatedArray(@D); sub nonDuplicatedArray #(@DuplicatedArray) { my @Duplicated=@_; my %seen=(); my (@NonDuplicatedArray,@Unique); @Unique = grep {! $seen{$_}++} @Duplicated; @NonDuplicatedArray = sort(@Unique); return @NonDuplicatedArray; }
(: Life is short enjoy it :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-19 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found