Use "use Fcntl ':mode';" to import S_I* constants. They are just bitmasks that masks bits from portions of files permissions. In Unix systems they are grouped into 4 groups of 3 bits. First three are for setuid(4), setgid(2), stickybit(1). Other three groups of bits are for user, owner group and others. Permissions are read(4), write(2) and execute(1).
Permissions are often represented in octal form, so for this permission "rwxr-x-w-" you will have octal one 0752.
I recommend you reading "perldoc -f stat" document, you have it all there. Except some of the stuff about inner working, which you could find in "info glibc" if you are working on some Linux system.
Code from stat doc page:#!/usr/bin/env perl use Fcntl ':mode'; use strict; use warnings; my $mode = (stat($ARGV[0]))[2]; my $user_rwx = ($mode & S_IRWXU) >> 6; my $group_read = ($mode & S_IRGRP) >> 3; my $other_execute = $mode & S_IXOTH; printf "Permissions are %04o\n", S_IMODE($mode), "\n"; my $is_setuid = $mode & S_ISUID;
In reply to Re^2: check if file is executable by user/group/world?
by XooR
in thread check if file is executable by user/group/world?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |