perl - perl 的 int(-M $file) 有什么作用?

标签 perl file

我正在查看一些较旧的 perl 代码,我可以看到有人正在使用以下命令比较目录中各种文件的时间戳:

int(-M $filename);

这到底是做什么的?我查看了文档中的 int() 条目,但找不到有关 -M 标志的任何信息。

最佳答案

那是一个文件测试操作符-X

  • -X FILEHANDLE
  • -X EXPR
  • -X DIRHANDLE
  • -X

    A file test, where X is one of the letters listed below. This unary operator takes one argument, either a filename, a filehandle, or a dirhandle, and tests the associated file to see if something is true about it. If the argument is omitted, tests $_ , except for -t , which tests STDIN. Unless otherwise documented, it returns 1 for true and '' for false. If the file doesn't exist or can't be examined, it returns undef and sets $! (errno). Despite the funny names, precedence is the same as any other named unary operator. The operator may be any of:

    ...
    31.  -M  Script start time minus file modification time, in days.
    

关于perl - perl 的 int(-M $file) 有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24940384/

相关文章:

perl - 驼鹿和扩展非驼鹿类

windows - Windows Server 2008 上的 Perl?

perl - 如何全局声明一个变量,使其对所有 perl 模块都可见?

r - 如何循环遍历 R 中的 CSV 文件文件夹

python - 从特定文本行读取文件

c# - 在 C# 中枚举文件句柄

perl - 你能 tie() 一个没有裸字 glob 的文件句柄吗?

php - 如何检测图像是 PNG 还是 APNG 格式?

C:将文本文件读入结构数组

c - C 中推箱子游戏加载程序的段错误