$counts{$_}++ for @test; #### for (@test) {$counts{$_}++} #### @redundant = grep {++$counts{$_} > 1} @test; #### @redundant = grep {++$counts{$_}==2} @test;