in reply to advancing in file read

Use a while loop instead, and then just do another $line = <TF>; within the loop body. This will both read the next line and advance the file pointer.

while ($line = <TF>) { ... $line = <TF>; }

The problem with the for loop is that all the lines already have been read (because of <TF> being in list context) before the loop starts iterating.

Replies are listed 'Best First'.
Re^2: advancing in file read
by cammac (Acolyte) on Jun 01, 2010 at 16:21 UTC
    Thanks!