in reply to file processing, while and foreach: a n00b experience
It helps to know that
is equivalent towhile (<FH>) {
and that foreach (LIST) flattens the list it gets. (Well, there are some special cases like foreach (ARRAY) and foreach (RANGE) that are more efficient.)while (defined($_ = readline *FH)) {
See the documentation on readline to find out how it behaves differently when used in list context.
In Perl 6, this will not be much of a problem, since it will have "lazy lists". A normal for (LIST) will do what you mean, in an efficient way.
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: file processing, while and foreach: a n00b experience
by Aristotle (Chancellor) on Aug 28, 2003 at 12:12 UTC | |
|
Re: Re: file processing, while and foreach: a n00b experience
by John M. Dlugosz (Monsignor) on Sep 02, 2003 at 20:39 UTC |