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 ( #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


Comment on Re: open vs sysopen
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2014-09-21 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls