Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: What happens when I use a filehandle

by RobPayne (Chaplain)
on Jan 06, 2007 at 16:25 UTC ( #593306=note: print w/replies, xml ) Need Help??

in reply to What happens when I use a filehandle

You have already gotten good answers on why it is best to not open a filehandle before you need it, and why you should get in the habit of closing it when you are done.

Another advantage to closing the filehandle yourself rather than allowing the garbage collector to close it for you, is that you can check the return status. If all buffers could not be flushed when the close occurs, the only way you will know is if you run the close and check the status, like this pseudo-code:

close (FH) or die "Could not write all data to $file_or_pipe: $!";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://593306]
[ambrus]: So that, or if you really want something agnostic to the loop, then use curl multi. Its interface is quite reasonable (unless you use an old version),
[ambrus]: though it's very C-like (serious use of varargs so easy to pass the wrong type), and there are some minor problems (busy loop because it doesn't use the same timer as your event loop, so you have to artificially delay timer callbacks by a small amount).

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2016-12-07 16:23 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (130 votes). Check out past polls.