Movatterモバイル変換


[0]ホーム

URL:


functions /chmod
(source,CPAN)
You are viewing the version of this documentation from Perl 5.32.1.View the latest version
#chmod LIST

Changes the permissions of a list of files. The first element of the list must be the numeric mode, which should probably be an octal number, and which definitely shouldnot be a string of octal digits:0644 is okay, but"0644" is not. Returns the number of files successfully changed. See alsooct if all you have is a string.

my $cnt = chmod 0755, "foo", "bar";chmod 0755, @executables;my $mode = "0644"; chmod $mode, "foo";      # !!! sets mode to                                            # --w----r-Tmy $mode = "0644"; chmod oct($mode), "foo"; # this is bettermy $mode = 0644;   chmod $mode, "foo";      # this is best

On systems that supportfchmod(2), you may pass filehandles among the files. On systems that don't supportfchmod(2), passing filehandles raises an exception. Filehandles must be passed as globs or glob references to be recognized; barewords are considered filenames.

open(my $fh, "<", "foo");my $perm = (stat $fh)[2] & 07777;chmod($perm | 0600, $fh);

You can also import the symbolicS_I* constants from theFcntl module:

use Fcntl qw( :mode );chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @executables;# Identical to the chmod 0755 of the example above.

Portability issues:"chmod" in perlport.

Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.

The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.


[8]ページ先頭

©2009-2025 Movatter.jp