Greetings,
First some suggestions, against using barewords, and for using open in its three terms form: more explicit and understandable
Also I put there use autodie because I'm lazy :$
use warnings;
use strict;
use autodie;
open my $in,'<', "in.txt";
open my $out,'>', "out.txt";
Since you start at first line and then jump over each line to save to the previous line you can use the perl auto variable for line counts
my $previous_line;
while (<$in>) {
$current_line = $_;
chomp $current_line;
if(!defined($previous_line) || $. mod 2 != 0){
$previous_line = $current_line;
next;
}
my @previous_columns = split(" ", $previous_line);
my $end_coor = $previous_columns[2] + $previous_columns[3];
my @current_columns = split(" ", $current_line);
my $seq_length = length $previous_columns[6];
my $gap_count = $previous_columns[6] =~ tr/Q//;
my $original_length = $seq_length - $gap_count;
my $original_end_coor = $previous_columns[2] + $original_length;
my $distance = $current_columns[2] - $original_end_coor;
$current_columns[2] = $end_coor + $distance;
$previous_line = $current_line;
print $out "$current_columns[2]\n";
}
close $in;
close $out;
I'm not sure about the way you want to go over the file though, do you want to just jump over half of the lines?