Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Using more than one filehandle

by matija (Priest)
on Mar 24, 2004 at 14:41 UTC ( [id://339412]=note: print w/replies, xml ) Need Help??


in reply to Using more than one filehandle

When you say "at once" do you mean, "at the exact same moment in time", or do you mean "I need to files opened at the same time"?

If the former, no single CPU computer can do it, but some multiprocessor machines may be able to, provided their operating system supports it.

If the later (more probable), then there is no problem:

open(FILE1,"</some/file/somewhere") || die "Could not open FILE1: $!\n +"; open(FILE2,"</some/other/file") || die "Could not open FILE2: $!\n";
At this point you have two files open and you can read from the first with <FILE1> and from the second with <FILE2>.

Or, if you open the files for writing, you can write to them like this:

print FILE1 "something to be written to FILE1\n";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-28 22:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found