If I understand your description of the task, it looks like your two snippets of sample data are different in ways that they shouldn't be -- that's a bit confusing.
But based on your description (and assuming that the input data is correctly sorted according to the values of the "reference_position_begin" and "reference_position_end" columns), I think the following would do what you want:
#!/usr/local/bin/perl
use strict;
use warnings;
my $prev_key = '';
my $match_count;
while (<>) {
my @flds = split;
my $key = join ' ', @flds[6,7];
$match_count = 0 if ( $key ne $prev_key );
$prev_key = $key;
splice( @flds, 6, 0, ++$match_count );
print join( "\t", @flds ), "\n";
}
If the input data isn't sorted properly yet, just look up the unix "sort" command to take care of that.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.