$mode = (stat($filename))[2];
printf "Permissions are %04o\n", $mode & 07777;
Run Code Online (Sandbox Code Playgroud)
其他示例要求您知道模式是stat输出中的第三项(即[2]).File :: stat允许您提供符号名称.
use File::stat ;
my $dir = '/etc/cron.d' ;
printf "%o", stat($dir) -> mode ;
Run Code Online (Sandbox Code Playgroud)