Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: capturing syswrite failures

by jettero (Monsignor)
on Mar 01, 2007 at 17:39 UTC ( [id://602729]=note: print w/replies, xml ) Need Help??


in reply to capturing syswrite failures

Additionally, why are you using syswrite? Perl does a pretty darn good job of hiding some important details from you when you use open/print/close and you get pretty much the same functionality — not the least of which is better error handling. I'm wondering if you'd be better off using print along with local $| = 1 or something like that?

-Paul

Replies are listed 'Best First'.
Re^2: capturing syswrite failures
by bluto (Curate) on Mar 01, 2007 at 19:48 UTC
    print makes sense if you turn off buffering -- which is pretty close to the same as using syswrite. If buffering is involved, print makes it very hard to recover and continue after an error since the error can be deferred. You also need to remember to do an explicit close and check the error on that.

    For example, if NFS returns ESTALE (e.g. after a server reboot), you may have to close and reopen the file before the NFS server will allow you to write. That close is going to try, and fail, to send the buffered data. Figuring out what data to resend in this case is easy with syswrite (e.g. close, open, syswrite the buffer again).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2024-04-25 11:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found