It's not wrong, but I've seen it used quite a bit by new perl programmers, and I wonder why they prefer that to using the while (<DAT>) {...} construct. In fact, often I see <...> used in array context immediately followed by a foreach loop iterating over the array, and it makes me cringe.@A = <DAT>;
Like I said, it's not a wrong practice. It can be more wasteful of memory than a while loop, but on today's hardware that's probably not a big concern. Is it just conceptually easier to think in terms of "read the data into an array and then iterate over the array" as opposed to "read in a line and process it"? In most other programming languages the while loop approach is the only way to process a file a line at a time, so I wonder why I see this practice so much.
Anyway, any insight into why you decided to use @A = <DAT>, where you've seen it or picked it up from would be helpful. Thanks!
In reply to Re: Using a loop to process multiple files
by pc88mxer
in thread Using a loop to process multiple files
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |