my $previous = ''; while (<>) { @gtf = split /\s+/, $_; chomp(); if ("$gtf[9]" ne "$previous") { $gtf[2] =~ tr/ex*/ex1/; } else { $gtf[2]++; } }