in reply to Using a loop to process multiple files
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using a loop to process multiple files
by dragonchild (Archbishop) on May 08, 2008 at 22:32 UTC | |
|
Re^2: Using a loop to process multiple files
by Anonymous Monk on May 08, 2008 at 22:59 UTC | |
by chromatic (Archbishop) on May 08, 2008 at 23:51 UTC | |
by Anonymous Monk on May 09, 2008 at 00:55 UTC | |
|
Re^2: Using a loop to process multiple files
by wfsp (Abbot) on May 09, 2008 at 07:08 UTC | |
|
Re^2: Using a loop to process multiple files
by Anonymous Monk on May 08, 2008 at 22:48 UTC | |
by TGI (Parson) on May 08, 2008 at 23:18 UTC |