#! perl -slw use strict; use Inline::Files; my $tally = ''; m[rs(\d{7})] and vec( $tally, $1 - 1e6, 1 ) = 1 while ; m[rs(\d{7})] and vec( $tally, $1 - 1e6, 1 ) and print while ; __DATA__ __FILE1__ chr1 11223 11224 rs2342349 chr2 23423 23424 rs6345435 chr3 64564 64565 rs3432456 chr4 56456 56457 rs7979979 __FILE2__ rs2342349 rs3274234 rs2342344