Perl Programming/Keywords/sysopen

The sysopen keyword
The sysopen command opens the file whose filename is given by FILEHANDLE, and associates it with the FILEHANDLE, which may be an expression where its value is the real filehandle. The function calls the open(2) function of the underlying operating system and depends on the fdopen C library function.

Values of the MODE parametre are system-dependent and are available over the standard module Fcntl. These values are <tt>O_RDONLY</tt> (=<tt>0</tt>), <tt>O_WRONLY</tt> (=<tt>1</tt>), <tt>O_RDWR</tt> (=<tt>2</tt>) for opening the file read-only, write-only, and read-write, respectively. The values do not work on some operating systems, such as OS/390 and Macintosh.

Many systems support also the <tt>O_EXCL</tt> flag that opens the file in the exclusive mode, which does not mean a lock, but that if the file already exists, <tt>sysopen</tt> fails. <tt>O_EXCL</tt> may not work on network filesystems, or if the <tt>O_CREAT</tt> flag is not set. The <tt>O_TRUNC</tt> can be used to truncate a file.