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

Re: Remove Duplicates from Array

by friedo (Prior)
on Oct 31, 2008 at 20:58 UTC ( #720784=note: print w/replies, xml ) Need Help??


in reply to Remove Duplicates from Array

Using the @ in front of a hash means you're doing a hash slice, which allows you to assign multiple values to multiple keys in one step. In this case, you're creating keys out of the values in @array, and assigning them all undef (since you've got an empty list on the right-hand side of the assignment.)

Then you extract all the keys from the hash using the keys function. Since making a duplicate hash key does not add a new key to a hash, this has the effect of removing all duplicates.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://720784]
help
Chatterbox?
[stevieb]: berrybrew has been updated with the new perl checksums. Now I'm going to implement dynamic loading of perls thanks to their new JSON releases file
[LanX]: GotToBTru ++ # erix & MySql ... talk about a database trigger xD

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2017-03-30 16:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (360 votes). Check out past polls.