sysopen (Advanced open)

The sysopen function call gives you greater control over the opening of a file handle. The format of this function call is similar to that of the C open function:

sysopen FILEHANDLE,FILENAME,MODE [, PERMS];

In this case, FILEHANDLE is the file to be opened. The FILENAME is the name of the file to be opened. MODE is open mode. It can be 0 for read, 1 for write, and 2 for read write; however, these values may not work on some operating systems such as Macintosh.

Or you can use the package Fcntl to bring in the symbols O_RDONLY, O_WRONLY, and O_RDWR. This module provides all the flags available on your system. Other flags such as O_APPEND and O_NONBLOCK are available as well.

Finally, if you are creating a file, the PERMS parameter specifies the permissions to be used. (Permissions correspond to the UNIX permission bits if you’re on UNIX. If you’re on Microsoft Windows, these bits are ignored.)

For example, suppose that you want to open a file for reading and writing with permissions that allow everyone to read and write the file. You would use the sysopen call:

use Fcntl; 
sysopen DATA_FILE, "data.txt", O_RDWR, 0666;

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset