http://qs321.pair.com?node_id=261139


in reply to Multiple text files

My problem is I can read a text file within a file but I can't go back to my main file
Man, that doesn't make any sense. It sounds like you're saying once you read a line from the second file, your access to the main text file is revoked, or the main file gets closed... You do know you can have multiple file handles open in perl, right?

Replies are listed 'Best First'.
Re: Re: Multiple text files
by Anonymous Monk on May 29, 2003 at 16:24 UTC
    Yes I do know I can have multiple file handles. Let me try to explain this another way. I have file1 which is the main file. This file is to stay open always. I only access a line in file2 if this condition exist:

    if what I'm reading in file1 is true, then I go to file2 and get that line of data. if it's false I want to stay in file1 and print my output.

    The problem is once I open file2 it reads the whole file and never goes back to file1. When I look at my output, it prints the first line of file1 because the condition is false. Then it prints the first line of file2 b/c the condition is true. So it goes to the file but it reads and prints the whole file. It doesn't check the next line of data from file1. I never see when the condition is false and stay in file1 again.
      Thanks for your help. I got it!!!!