S_ISREG#
True if a stat-mode value names a file of the predicate’s type: S_ISREG a regular file, S_ISDIR a directory, S_ISLNK a symbolic link, S_ISSOCK a socket, S_ISBLK a block device, S_ISCHR a character device, S_ISFIFO a named pipe.
Also available as Fcntl::S_ISDIR, Fcntl::S_ISLNK, Fcntl::S_ISSOCK, Fcntl::S_ISBLK, Fcntl::S_ISCHR, Fcntl::S_ISFIFO.
Synopsis#
my $mode = (lstat $path)[2];
print "plain file\n" if S_ISREG($mode);
print "symlink\n" if S_ISLNK($mode);
Returns true (1) when ($mode & S_IFMT) is the predicate’s S_IF* value, false ("") otherwise. With no argument, warns “Use of uninitialized value” and returns false. Use lstat rather than stat for S_ISLNK: plain stat follows symlinks and reports the target’s mode. S_ISWHT exists only where the system has whiteouts, which Linux does not.