s_imode#

Extract the permission bits from a stat-mode value.

Synopsis#

my $perm = S_IMODE($mode);

Returns $mode & 07777 — the nine permission bits plus the setuid, setgid, and sticky bits. Strips the file-type bits that S_IFMT would keep. With no argument, returns 0.

Examples#

use Fcntl qw(:mode);
my $mode = (stat $path)[2];
printf "perms = %04o\n", S_IMODE($mode);   # perms = 0644