in reply to rename duplicate data
Or a variation of the above solution:
use Modern::Perl; my %hash; do {chomp; $_ = qq|$_"$hash{$1}"| if /(ID=.+)$/ and ++$hash{$1}; say} for <DATA>; __DATA__ xxxx . yyy 521 916 . + . ID=OSCAR1028v1rpkm9.67 xxxx . xxx 521 567 . + . Parent=OSCAR1028v1rpkm9.67 xxxx . yyy 126 130 . - . ID=OSCAR10281vrpkm9.67 xxxx . xxx 129 130 . - . Parent=OSCAR1028v1rpkm9.67 xxxx . yyy 126 130 . - . ID=OSCAR10281vrpkm9.67 xxxx . xxx 129 130 . - . Parent=OSCAR1028v1rpkm9.67
Results:
xxxx . yyy 521 916 . + . ID=OSCAR1028v1rpkm9.67"1" xxxx . xxx 521 567 . + . Parent=OSCAR1028v1rpkm9.67 xxxx . yyy 126 130 . - . ID=OSCAR10281vrpkm9.67"1" xxxx . xxx 129 130 . - . Parent=OSCAR1028v1rpkm9.67 xxxx . yyy 126 130 . - . ID=OSCAR10281vrpkm9.67"2" xxxx . xxx 129 130 . - . Parent=OSCAR1028v1rpkm9.67
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: rename duplicate data
by blacknight (Initiate) on Jun 22, 2012 at 12:46 UTC | |
by Kenosis (Priest) on Jun 22, 2012 at 16:37 UTC | |
by Anonymous Monk on Jun 24, 2012 at 20:36 UTC | |
by blacknight (Initiate) on Jun 26, 2012 at 11:11 UTC | |
by Athanasius (Archbishop) on Jun 26, 2012 at 12:00 UTC |