in reply to Re^2: how to reset the input operater in while loop?
in thread how to reset the input operater in while loop?

The time to open and close the files is completely insignificant compared to the time to read them, especially if the files are large. You really don't want to do it that way!

Tell us about the bigger picture. It is almost certain that there is a better way of achieving what you want to do than reparsing one of the files once for each line of another file. It may be that you need to sort the files first, or use a database, or extract key information, but whatever the technique, it will be much faster than the scheme you are currently considering.


Perl reduces RSI - it saves typing
  • Comment on Re^3: how to reset the input operater in while loop?

Replies are listed 'Best First'.
Re^4: how to reset the input operater in while loop?
by graff (Chancellor) on Oct 01, 2008 at 04:13 UTC
    The time to open and close the files is completely insignificant compared to the time to read them, especially if the files are large.

    On the other hand, if the files are small, and you happen to open and close them lots of times, then you find out that the process of opening and closing is also very costly, compared to having memory-resident data that you just use over and over within loops. I would not consider the time taken to open and close files to be "completely insignificant".