- 论坛徽章:
- 0
|
# data input
my $line;
my (@start, @end);
my $i;
while ($line = <>) {
chomp($line);
my ($start, $end) = split(/\s+/, $line);
print "$start\t\t$end\n";
push @start, $start;
push @end, $end;
}
print "\n\n";
# data merge
my (@first, @second);
if (@start) {
push @first, $start[0];
for ($i=0; $i<$#start; $i++) {
if ($end[$i] - $start[$i + 1] != 1) {
push @second, $end[$i];
push @first, $start[$i + 1];
}
}
push @second, $end[-1];
}
# show result
print "\n\n";
for ($i=0; $i<@first; $i++) {
print "$first[$i]\t\t$second[$i]\n";
}
|
|