Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 romping around the Monastery: (9)
As of 2015-07-08 08:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (96 votes), past polls