Before foreach can iterate over the list, it needs to be built. It works the same way for function. A list must be built before it can be used. In this case, building the list means reading the entire file.
foreach (x..y) is an exception to this. That list is evaluated lazily.
In reply to Re^3: Odd behaviour with $. and <DATA>
by ikegami
in thread Odd behaviour with $. and <DATA>
by talexb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |