Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by merlyn (Sage)
on Oct 14, 2002 at 16:19 UTC ( #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? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2021-07-30 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?