Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对 perl 中方括号逗号分隔元素的使用感到困惑:
[short($file), -s $file];
有人能告诉我这段代码是什么意思吗?
[]创建一个数组引用。
[]
[ $scalar, $scalar ]创建一个包含两个项目的数组引用。
[ $scalar, $scalar ]
short($file)调用一个子程序并返回一些东西(可能是一个标量或一个标量列表)
short($file)
-s $file为您提供文件的大小(作为标量)。
-s $file
[short($file), -s $file]给你一个包含上述两件事的数组 ref。
[short($file), -s $file]
它创建对包含两项的数组的引用,即函数调用的结果short($file)和$file.
$file