in reply to Re^7: Comparing adjacent lines
in thread Comparing adjacent lines

The problem here is that you're getting your $exon variable confused with $gtf[2]. You're using $exon to hold the counter which you increment on matching lines, but then you clobber it by assigning $gtf[2] to it after that, but then you don't use it after that. Also, if you're going to use a counter, you don't need to use a regex to increment the digit part of the field. Also, there's no need for an elsif when there are only two possibilities (eq and ne).

if ( $gtf[9] ne $previous ){ $exon = 1; # reset counter } else { $exon++; # increment counter } $gtf[2] = "exon$exon"; # put counter back in field

Aaron B.
Available for small or large Perl jobs; see my home node.

Replies are listed 'Best First'.
Re^9: Comparing adjacent lines
by daccame (Initiate) on Jul 16, 2012 at 22:06 UTC

    Perfect!! Thank you.

    Most of those things you pointed out were an accumulation of different things I tried...and then forgot to clean up afterwards. You have been incredibly helpful, thanks again.