无涯教程-Perl - chmod函数

65 阅读1分钟

描述

此功能将LIST中指定的文件模式更改为指定的MODE。 MODE的值应为八进制。您必须对照尝试更改的文件数检查返回值,以确定操作是否失败。此功能调用等效于Unix命令chmod MODE FILELIST 。

语法

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

chmod MODE, LIST

返回值

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

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

#!/usr/bin/perl

cnt=chmod0755,foo,bar;chmod0755,@executables;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

参考链接

www.learnfk.com/perl/perl-c…