in reply to Line number problem with foreach
use strict; use warnings; my @a=(1,2,3,4,5); foreach (@a) { print $_; }
The foreach will accept a list so that the foreach expands as follows.
foreach (1,2,3,4,5);
Similar to that while reading the file contents, it will read the whole file content and $. will set to the last line number.
|
|---|