in reply to occurence of repeated numbers group
#!/usr/bin/perl # https://perlmonks.org/?node_id=1218823 use strict; use warnings; my %dups; local $_ = do { local $/; <DATA> }; /\b(\d+)\b.*?\b(\d+)\b(?{$dups{"$1 $2"}++})(*FAIL)/; $dups{$_} > 1 and print "$_ repeated $dups{$_} times\n" for sort keys +%dups; __DATA__ 1 2 5 9 1 2 5 10 4 5 10 12 5 9 10 11
Outputs:
1 2 repeated 2 times 1 5 repeated 2 times 2 5 repeated 2 times 5 10 repeated 3 times 5 9 repeated 2 times
|
|---|