当前位置: 首页 > 文档资料 > Perl 入门教程 >

chmod

优质
小牛编辑
122浏览
2023-12-01

描述 (Description)

此功能将LIST中指定的文件模式更改为指定的MODE。 MODE的值应为八进制。 您必须根据尝试更改的文件数检查返回值,以确定操作是否失败。 这个函数调用相当于Unix Command chmod MODE FILELIST

语法 (Syntax)

以下是此函数的简单语法 -

chmod MODE, LIST

返回值 (Return Value)

此函数返回Integer,成功更改的文件数。

例子 (Example)

以下是显示其基本用法的示例代码 -

#!/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
<!--

When above code is executed, it produces the following result −

-->