Again assuming you are processing a static file, I would tend to attack the problem this way:
-
Define a regex to recognize and extract a unique UID. Something like
my ($uid) = $line =~ m{ <uid= (\w+) }xms;
seems like a good first guess.
-
Define a regex to recognize (and, if necessary, to extract) whatever an 'occurrence' may be.
-
If both a UID and an occurrence occur in a line, increment a UID count as appropriate to the occurence. This may be as simple as
my %occurrences;
# enter line processing loop
# ..., recognize occurrence, extract UID from line, ...
$occurrence{$uid}++;
# process next line, etc.
if all occurrences have equal weight.
-
When all lines in the file are processed, loop through the hash and send an appropriate message for each UID for which the count of occurrences exceeds the specified threshold.
| [reply] [d/l] [select] |