perl中的-e, -z, -s, -M, -A, -C, -r, -w, -x, -o, -f, -d , -l

Perl的-X运算符用于测试文件或目录的各种属性,如读取、写入、执行权限,文件大小,修改时间等。它们返回true或false。例如,-s返回文件大小,-M、-A、-C分别返回文件的修改、访问和inode改变日期。这些日期以与脚本开始时间的天数差值表示。本文提供了这些运算符的详细说明和示例。
摘要由CSDN通过智能技术生成

非原创,来自链接

https://perlmaven.com/file-test-operators

Perl has a bunch of strange-looking unary operators that all look like this -X. They can act on any file or directory name or any file or directory handle.

They return various information about the specific file or directory.

Most of them return true or false and normally you would write something like this:

my $filename = "bla/bla/bla.txt";
if (-e $filename) {
    print "The file '$filename' exists\n";
}

-s returns the size of the file so you could write:

my $size = -s $filename;

The -M, -A, -C return the modification, access and inode change dates on Unix/Linux like systems. On Windows, I think only -M is available. In any case they work in a very str

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值