Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: open vs sysopen

by tomfahle (Priest)
on Jun 02, 2010 at 13:02 UTC ( [id://842755]=note: print w/replies, xml ) Need Help??


in reply to open vs sysopen

As stated before sysopen comes with more precision than open.

sysopen helps avoiding race-conditions.

Consider the following snippet:

if (-e $file) { open(FH,">","$file") or die $!; }

It's a two step process:

  1. File test
  2. open

sysopen needs only one step (kind a simplistic, but you should get the message).

use Fcntl; sysopen(FH, $file, O_WRONLY|O_TRUNC|O_CREAT, 0600) or die $!;

HTH,
Thomas

Log In?
Username:
Password:

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

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

    No recent polls found