The example given by
draconis only provides the "owner/group/other" mode flags for the file in question. It looks like the OP was asking how to learn what sort of access is available to the person running the perl script.
In order to do that, you would need to combine the mode field from stat with knowledge of the current user's group membership(s) and whether the current user happens to be the owner of the file, so you'll know which set of bits from the mode flag are relevant for determining file access.
A better way for the task at hand would be:
($r,$w,$x) = (-r $path, -w _, -x _);
print "Access: read $r, write $w, execute (search dir) $x\n";
A few notes:
- using underscore as the argument for "-w" and "-x" tells perl to use the same "stat" data obtained by "-r"
- as written above, any permission not granted will be "undef", so the printed message in this case would look like "read 1, write , execute (search dir) 1" when there is no write permission
- contrary to derby's comment, "execute" permission on a directory does not control whether or not you can "cd" into that directory; it does determine whether you can "search" the directory contents -- i.e. you need execute permission to run "ls" with no args, or "find", or do any sort of operation using "*" or "?" as part of a file name within the directory.