Perlfunc: get_file_perm() 2008-06-26 11:53am
Quick function to get the permissions of a file with Perl.
Code:
sub get_file_perm {
my $file = shift();
# Permissions are the second element of stat
my $mode = (stat($file))[2];
my $perm = sprintf("%04o",$mode & 07777);
return $perm;
} |