This section provides a tutorial example on using file test operators to return information about a file or a directory in the file system. For example, -e tests if a file exists or not.
Perl offers a number of unary operators to return statistics of a file or a directory in the file system.
Some commonly used ones are:
"-e path_name" returns 1, if the path name exists.
"-z path_name" returns 1, if the path name has zero size.
"-s path_name" returns the size of the path name.
"-f path_name" returns 1, if the path name is a file.
"-d path_name" returns 1, if the path name is a directory.
"-T path_name" returns 1, if the path name is a text file.
"-B path_name" returns 1, if the path name is a binary file.
Here is a tutorial example script of using file test operators: