in reply to Finding maximum number of duplicates in an array

I'm not sure I've understood your requirement but is this what you meant?

$ perl -Mstrict -Mwarnings -MList::Util=reduce -E ' > my @arr = qw{ a c b d b a b e f }; > my %dup; > push @{ $dup{ $arr[ $_ ] } }, $_ for 0 .. $#arr; > my $maxKey = > reduce { scalar @{ $dup{ $a } } > scalar @{ $dup{ $b } } ? $a : $ +b } > keys %dup; > say qq{Max dups for "$maxKey" at elements @{ $dup{ $maxKey } }};' Max dups for "b" at elements 2 4 6 $

I hope I've guessed correctly and that this is helpful.

Cheers,

JohnGG