SPUG: finding the permissions
C.J. Collier
cjcollier at pobox.com
Fri Feb 1 17:11:47 CST 2002
see 'perldoc -f stat'
excerpt:
stat FILEHANDLE
stat EXPR
stat Returns a 13-element list giving the status info
for a file, either the file opened via FILEHANDLE,
or named by EXPR. If EXPR is omitted, it stats
$_. Returns a null list if the stat fails. Typi-
cally used as follows:
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);
(stat(FH))[2] will have the information about the mode (type &
permissions) of the file.
@info = stat("foo.txt");
printf("%04o\n", $info[2] & 0777);
This will print the mode (for instance 0664)
Hope this helps,
C.J.
On Fri, 1 Feb 2002, Douglas Kirkland wrote:
> I am trying to find the permission on a file. For some reason 'File::Copy'
> does not keep the same permission on the file that I am trying to copy. So I
> would like to get the permission of the file so I can set the file permission.
>
> Maybe I missed something with File::Copy.
>
> Douglas
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
> Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
> Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
> For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
> Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
>
>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list