in reply to Compute previous lines data
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:
If the input data isn't sorted properly yet, just look up the unix "sort" command to take care of that.#!/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"; }
|
|---|