gpt4 book ai didi

perl - 如何将 $^E 与数字进行比较?

转载 作者:行者123 更新时间:2023-12-04 14:12:50 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com