Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Multiple text files

by boo_radley (Parson)
on May 27, 2003 at 23:56 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-24 12:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found