Perl chmod 函式



描述

此函式將 LIST 中指定檔案的模式更改為指定的 MODE。MODE 的值應該是八進位制的。你必須將返回值與嘗試更改的檔案數進行比較,以確定操作是否失敗。此函式呼叫等效於 Unix 命令 chmod MODE FILELIST

語法

以下是此函式的簡單語法 -

chmod MODE, LIST

返回值

此函式返回成功更改的檔案數目。

示例

以下是顯示其基本用法的示例程式碼 -

#!/usr/bin/perl

$cnt = chmod 0755, 'foo', 'bar';
chmod 0755, @executables;
$mode = '0644'; chmod $mode, 'foo';      # !!! sets mode to # --w----r-T
$mode = '0644'; chmod oct($mode), 'foo'; # this is better
$mode = 0644;   chmod $mode, 'foo';      # this is best
perl_function_references.htm
廣告
© . All rights reserved.