perl-5.38.0
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 should not be a string of octal digits: 0644 is okay, but "0644" is not. Returns the number of files successfully changed. See also oct if all you have is a string.

LIST に含まれるファイルの、パーミッションを変更します。 LIST の最初の要素は、数値表現のモードでなければなりません; 恐らく 8 進表記の数であるべきでしょう: しかし、8 進表記の 文字列では いけません: 0644 は OK ですが、 "0644" は だめ、ということです。 変更に成功したファイルの数を返します。 文字列を使いたい場合は、oct を参照してください。

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

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

fchmod(2) に対応しているシステムでは、ファイルハンドルを引数として 渡せます。 fchmod(2) に対応していないシステムでは、ファイルハンドルを渡すと 例外が発生します。 ファイルハンドルを認識させるためには、グロブまたはリファレンスとして 渡されなければなりません; 裸の単語はファイル名として扱われます。

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

You can also import the symbolic S_I* constants from the Fcntl module:

Fcntl モジュールから S_I* シンボル定数を インポートすることもできます:

    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.

移植性の問題: "chmod" in perlport