in reply to How to continue numbering after a regular expression has been found
Your assignment to $counter is never executed at the right time because you do a next before it gets encountered. And if the 'if' is false, there shouldn't be an assignement to $counter but an increment. You probably want this:
while ( <DNAFILE> ) { if (/fixedStep chrom=chrX start=(.+) step=1/) { $counter = $1; next; } print "$counter\t$_\n"; $counter++; close DNAFILE;
Code is untested.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to continue numbering after a regular expression has been found
by jpoldot (Initiate) on Feb 11, 2011 at 12:49 UTC | |
by Ratazong (Monsignor) on Feb 11, 2011 at 13:01 UTC |