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