Problems? Is your data what you think it is? | |
PerlMonks |
Re^3: Reading file and matching linesby kcott (Archbishop) |
on Feb 14, 2014 at 00:33 UTC ( [id://1074918]=note: print w/replies, xml ) | Need Help?? |
Firstly, you have no duplicates in any (of what you're calling) "scope". G123465798 is not a duplicate of G123456798: you've transposed the 5 and the 6. I've fixed this in the example below. There's a standard idiom for checking for duplicates in this sort of scenario. Use a hash (often called %seen) that has as its keys whatever identifier you're checking. While processing, if the key exists, it's a duplicate, so skip/flag/etc. as appropriate; if the key doesn't exist, it's unique, so use it and then add it to the hash (usually done with a postfix increment). Here's an example using your fixed data:
Output:
-- Ken
In Section
Seekers of Perl Wisdom
|
|