in reply to Counting matches and removing duplicates

my %counts; while ( my $entity = ... ) { ++$counts{ $entity }; } for my $entity ( sort keys( %counts ) ) { say "$entity $counts{ $entity }"; }

Replies are listed 'Best First'.
Re^2: Counting matches and removing duplicates
by LexPl (Beadle) on Nov 15, 2024 at 13:33 UTC

    Many thanks for your input!

    I understand the two routines as such, but I don't understand how the different matching strings - all are XML entities - will be fed into the while loop.

    And to be honest; I didn't understand the suggestion about the hash solution

      It represents the existing loop you are using to discover the entities.