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.
In reply to Re: How to continue numbering after a regular expression has been found
by jethro
in thread How to continue numbering after a regular expression has been found
by jpoldot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |