加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

为什么在Perl chmod中使用int()?

发布时间:2020-12-15 22:04:42 所属栏目:大数据 来源:网络整理
导读:为什么在Perl文件中设置perms时需要使用int()函数? die "blab,blah" if (! chmod(int(0664),$tmp_file)); 我可以理解oct()的使用,如下面的perldoc示例所示: $mode = "0644"; chmod(oct($mode),$tmp_file); 但int()函数? 编辑 为了完整起见,这是perldoc -f
为什么在Perl文件中设置perms时需要使用int()函数?
die "blab,blah"
    if (! chmod(int(0664),$tmp_file));

我可以理解oct()的使用,如下面的perldoc示例所示:

$mode = "0644"; chmod(oct($mode),$tmp_file);

但int()函数?

编辑

为了完整起见,这是perldoc -f chmod的推荐……

$mode = 0644;   chmod $mode,"foo";      # this is best

解决方法

这绝对没有意义. 0664已经产生整数.
$perl -MDevel::Peek -e'Dump(0664)'
SV = IV(0x7a6118) at 0x7a6128
  REFCNT = 1
  FLAGS = (PADTMP,IOK,READONLY,pIOK)
  IV = 436

IOK表示标量包含整数值.

这肯定是有人以oct(“0644”)开头的结果,但是当他们离开使用字符串时却不太明白他们在做什么.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读