s_ifmt#
Extract the file-type bits from a stat-mode value.
Synopsis#
my $type = S_IFMT($mode);
my $mask = S_IFMT(); # the mask constant itself
Called with an argument, returns $mode & S_IFMT — the bits that
classify the file (regular, directory, symlink, …). Called with
no argument, returns the mask constant, which is how Perl code
commonly compares against S_IFREG, S_IFDIR, and friends.
Examples#
use Fcntl qw(:mode);
my $mode = (stat $path)[2];
print "is a directory\n" if S_IFMT($mode) == S_IFDIR;