in reply to Counting unique(ish) elements in a hash

As you have not given us a correct Perl structure for your data, a complete answer cannot be given. However, the code could look something like the one below, where you need to enter the correct pieces to loop over the entries under your keys yourself (replacing the ... with the appropriate (nested) loop).

for my $name ( keys %hash ) { my $count = 0; for my $entry ( ... ) { # loop over entries under first key $count++; print "$name $entry $count\n"; } }