in reply to Re^2: Line number problem with foreach
in thread Line number problem with foreach

In the C-style for-loop
foreach (;<$fh>;) { print " $. :$_ \n"; }
the initialization and finalization clauses of the loop (the parts before the first semicolon and after the second semicolon, respectively) are empty. The only clause specified is the conditional clause (between the two semicolons). When the  <> or readline operator is evaluated in the scalar context of the conditional, it returns a single line at a time until the file is exhausted, when it returns undef.

This is equivalent to reading  <$fh> in a while-loop.