in reply to Foreach & file io

By default, <> will read one line at a time. However, foreach builds up the list before iterating over it so the above code will read the entire file into memory and then start iterating over the lines.

For this type of thing you are much better off using while.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: Foreach & file io
by Xxaxx (Monk) on Jun 05, 2001 at 22:04 UTC
    Thanks tye,
    Based on the program's timing that is what it felt like. Hence checking with fell monks for the scoop. Much appreciated.

    Back to the while.
    Claude