File Test Operators





Perl has many operators that you can use to test different aspects of a file. For example, you can use the e operator to ensure that a file exists before deleting it, Or, you can check that a file can be written to, before appending to it. By checking the feasibility of the impending file operation, you can reduce the number of errors that your program will encounter. Pari's File Test Operators
- A OPERAND Returns the access age of OPERAND when the program started.
- b OPERAND Tests if OPERAND is a block device.
- B OPERAND Tests if OPERAND is a binary file. If OPERAND is a
file handle, then the current buffer is examined,
instead of the file itself.
- c OPERAND Tests if OPERAND is a character device.
-C OPERAND Returns the inode change age of OPERAND when the
program started.
-d OPERAND Tests if OPERAND is a directory.
- eOPERAND Tests if OPERAND exists.
- f OPERAND Tests if OPERAND is a regular file as opposed to a
directory, symbolic link or other type of file.
- g OPERAND Tests if OPERAND has the setgid bit set. (UNIX)
- k OPERAND Tests if OPERAND has the sticky bit set. (UNIX)
-l OPERAND Tests if OPERAND is a symbolic link. Under DOS,
this operator always will return false.
- M OPERAND Returns the age of OPERAND in days when the
program started.
-o OPERAND Tests if OPERAND is owned by the effective uid.
Under DOS, it always returns true. (UNIX)
- O OPERAND Tests if OPERAND is owned by the read uid/gid. Under
DOS, it always returns true. (UNIX)
- p OPERAND Tests if OPERAND is a named pipe.
- r OPERAND Tests if OPERAND can be read from.
- R OPERAND Tests if OPERAND can be read from by the real uid/
gid. Under DOS, it is identical to r. (UNIX)
- s OPERAND Returns the size of OPERAND in bytes. Therefore, it
returns true if OPERAND is non zero.
-S OPERAND Tests if OPERAND is a socket.
- t OPERAND Tests if OPERAND is opened to a tty.
- T OPERAND Tests if OPERAND is a text file. If OPERAND is a file
handle, then the current buffer is examined, instead
of the file itself.
-u OPERAND Tests if OPERAND has the setuid bit set. (UNIX)
- w OPERAND Tests if OPERAND can be written to.
-W OPERAND Tests if OPERAND can be written to by the real uid/
gid. Under DOS, it is identical to w.
(UNIX)
- x OPERAND Tests if OPERAND can be executed. (UNIX)
- X OPERAND Tests if OPERAND can be executed by the real uid/
gid. Under DOS, it is identical (UNIX) to x.
- z OPERAND Tests if OPERAND size is zero.
Domain Name Search
|