for takes a list, so it reads the entire file before iterating the loop. So, by the time you get to printing the lines within the loop, $. is set to the line number of the last line in the file. Using while instead of for will ensure that you process the file line by line.
In reply to Re: Line number problem with foreach
by BrowserUk
in thread Line number problem with foreach
by vinoth.ree
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |