Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Multiple text files

by boo_radley (Parson)
on May 27, 2003 at 23:56 UTC ( #261139=note: print w/replies, xml ) Need Help??

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!!!!

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://261139]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2023-03-26 09:14 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (63 votes). Check out past polls.