Saturday, July 9, 2011

Complete Guide to Perl File Test Operators and Syntax


File test operators in Perl allow you to check the status, permissions, and type of files or directories.

OperatorDescription
-rFile is readable by effective uid/gid.
-wFile is writable by effective uid/gid.
-xFile is executable by effective uid/gid.
-oFile is owned by effective uid.
-RFile is readable by real uid/gid.
-WFile is writable by real uid/gid.
-XFile is executable by real uid/gid.
-OFile is owned by real uid.
-eFile exists.
-zFile has zero size (is empty).
-sFile has nonzero size (returns size in bytes).
-fFile is a plain file.
-dFile is a directory.
-lFile is a symbolic link.
-pFile is a named pipe (FIFO), or Filehandle is a pipe.
-SFile is a socket.
-bFile is a block special file.
-cFile is a character special file.
-tFilehandle is opened to a tty.
-uFile has setuid bit set.
-gFile has setgid bit set.
-kFile has sticky bit set.
-TFile is an ASCII text file (heuristic guess).
-BFile is a "binary" file (opposite of -T).
-MScript start time minus file modification time, in days.
-ASame for access time.
-CSame for inode change time (Unix, may differ for other platforms).

No comments: