Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

•Re: Get All Duplicated Elements in an Array (Once, without shifting)

by merlyn (Sage)
on Oct 14, 2002 at 16:19 UTC ( [id://205138]=note: print w/replies, xml ) Need Help??


in reply to Get All Duplicated Elements in an Array (Once, without shifting)

Just grab them only the second time they're seen.
my @result = do { my %counter; grep ++$counter{$_} == 2, @input; };

-- Randal L. Schwartz, Perl hacker

  • Comment on •Re: Get All Duplicated Elements in an Array (Once, without shifting)
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-26 02:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found