Hi, I've been looking for a way to compare the current line in a loop to the previous line in the loop. I've been looking all day and can't seem to find an answer.
What I have so far:
my $previous = ''; while (<>) { @gtf = split /\s+/, $_; chomp(); if ("$gtf[9]" ne "$previous") { $gtf[2] =~ tr/ex*/ex1/; } else { $gtf[2]++; } }
Basically, I want to compare item 9 of @gtf in the current iteration with item 9 of @gtf from the last iteration and if they are different, restart the ex counter at 1. $gtf[2] is "ex1" and increases by 1 every iteration. Thanks!
In reply to Comparing adjacent lines by daccame
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |