or download this
Because the mode contains both the file type and its permissions, you
+should mask off the file type portion and (s)printf using a "%o" if y
+ou want to see the real permissions.
$mode = (stat($filename))[2];
printf "Permissions are %04o\n", $mode & 07777;