sysopen FILEHANDLE, FILENAME, MODE, PERMS sysopen FILEHANDLE, FILENAME, MODE |
相當於基礎C語言的操作係統調用open()。打開filename指定的文件,關聯它到FILEHANDLE。mode參數指定文件應該如何被打開。模式的值是依賴於係統,但也使用過往的某些值。 0,1和2的值的意思分彆是隻讀,隻寫和讀/寫。支持的值是在Fcntl模塊,並總結如下表所示。請注意,文件名FILENAME 是嚴格意義上的文件名;任何解釋的內容發生(不像打開),和打開的模式是由MODE參數定義。
如果文件被創建,O_CREAT標誌被指定在MODE,然後在文件被創建PERMS的權限。在傳統的Unix風格的十六進製的值PERMS必須指定。如果冇有指定PERMS,那麼Perl使用的缺省模式0666(讀/寫用戶/組/其他)。
Flag Description O_RDONLY Read only. O_WRONLY Write only. O_RDWR Read and write. O_CREAT Create the file if it doesn.t already exist. O_EXCL Fail if the file already exists. O_APPEND Append to an existing file. O_TRUNC Truncate the file before opening. O_NONBLOCK Non-blocking mode. O_NDELAY Equivalent of O_NONBLOCK. O_EXLOCK Lock using flock and LOCK_EX. O_SHLOCK Lock using flock and LOCK_SH. O_DIRECTOPRY Fail if the file is not a directory. O_NOFOLLOW Fail if the last path component is a symbolic link. O_BINARY Open in binary mode (implies a call to binmode). O_LARGEFILE Open with large (>2GB) file support. O_SYNC Write data physically to the disk, instead of write buffer. O_NOCTTY Don't make the terminal file being opened the processescontrolling terminal, even if you don.t have one yet.
0 - 失敗時
1 - 成功時