r File is readable by effective uid/gid. Despite the funny names, precedence is the same as any other named unary operator. Otherwise documented, it returns 1 for true and '' for false, or the undefined value if the fileĭoesn’t exist. If the argument is omitted, tests $_, except for "-t", which tests STDIN. This unary operator takes one argument,Įither a filename, a filehandle, or a dirhandle, and tests the associated file to see if something is
X A file test, where X is one of the letters listed below. Same for inode change time (Unix, may differ for other platforms) Script start time minus file modification time, in days. The perlfunc documentation covers the long list of Perl's file-test operators that covers many situations you will encounter in practice.įile has nonzero size (returns size in bytes).įile is a symbolic link (false if symlinks aren’t supported by the file system).įile is a named pipe (FIFO), or Filehandle is a pipe.įile is an ASCII or UTF-8 text file (heuristic guess).įile is a “binary” file (opposite of -T). print "$base_path is a plain file!\n" if -f $base_path The -f file-test operator asks whether a path leads to a plain file. TGZ in your question, it seems that you expect a plain file rather than the alternatives.
The code above will generate output if a plain file exists at that path, but it will also fire for a directory, a named pipe, a symlink, or a more exotic possibility. However, this test is probably broader than you intend. print "$base_path exists!\n" if -e $base_path Test whether something exists at given path using the -e file-test operator.