use strict;
use warnings;
open(FILE, "<", "Q.txt");
my @column=(<FILE>); #get the lines from the standard input into an
+ array
my $file;
chomp $file;
my $number=0;
while($number <= $#column) { #go through the array from
+0 to the last element
my $j;
my $count=0;
foreach ($j=$number; $j < $#column; $j++) { #select t
+he numbers from the beginning of the line in the current and next ele
+ment
my $d=($column[$j]=~/(\d+)/)[0] - ($column[$j+1]=~/(\d
++)/)[0]; #difference
last if abs($d)!= 1; #if differ more than 1 - le
+ave
$count+=$d; #accumulate the difference
}
if(abs($count)>=7) {
chomp($column[$_]);
$column[$_]=$column[$_]. "\tIN\n" for $number..$j;
+ #IN if >8
$number=$j+1;
}
if (abs($count)<8) {
chomp($column[$number]);
$column[$number] = $column[$number]."\tOUT\n";
+ #OUT if < 8
$number++;
}
}
print for @column;
|