我正在查看一些旧的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 testsSTDIN
. Unless otherwise documented, it returns1
for true and''
for false. If the file doesn't exist or can't be examined, it returnsundef
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.
perldoc -f -M
(或查看在线版本) - ThisSuitIsBlackNot-M
不是int()
的“标志”。就像int(age_of($bob))
可能会将 Bob 的年龄向下舍入到最近的整数。age_of
不是int()
的“标志” - 相反,age_of
的输出成为int()
的输入。 - tobyink