in reply to Re: How to read in large files
in thread How to read in large files
Corion has correctly identified the issue, but I think a little more explanation might be helpful. When you use foreach, perl constructs the entire list before iterating over it. Using while, on the other hand, executes exactly 1 read attempt per loop since while executes after each true evaluation (successful read). In addition, the stored value goes out of scope at the end of each iteration, thus you only store 1 line at a time instead of all of them.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to read in large files
by davido (Cardinal) on Jan 28, 2016 at 16:42 UTC | |
by Only1KW (Sexton) on Jan 28, 2016 at 17:33 UTC |