在 https://stackoverflow.com/a/3220688/180275答案表明(在 open
之后)$^E
可以与 0x20 进行比较以确定文件是否正在被另一个进程使用:
open ($fh, "<", "the-file");
if ($^E == 0x20) {
...
}
我已经试过了,它的工作原理。但是,如果我打印
$^E
的值我得到一个字符串( The process cannot access the file because it is being used by another process
)。那么如何与一个数字进行比较呢?
这是在 Windows 上。
最佳答案
>perl -E"open my $fh, '<', 'nonexistent'; say 0+$^E; say ''.$^E;"
2
The system cannot find the file specified
赞
$!
, $^E
是一个对偶变量,一个包含两个值的标量。一个是字符串,一个是数字。>perl -E"say $^E = 0x20;"
The process cannot access the file because it is being used by another process
关于perl - 如何将 $^E 与数字进行比较?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24757605/