运行 Perl 脚本时出现此错误:
Can't use an undefined value as filehandle reference at scr line 44.
第 44 行:
open my $fh, "|-", "mail", "-s", $subject, $owner, "-c", $sendto
or die "$0: could not start mail: $!";
一切看起来都很好。这个错误是什么意思?
最佳答案
我认为错误消息有误。这段代码:
open my $fh, '|-', 'perl', '-v' or die "$!\n";
因错误消息而死亡
Can't use an undefined value as filehandle reference...
在 Perl 5.6.1 下,但消失了
List form of pipe open not implemented...
在 Perl 5.12.1 下(在 Win32 上)。
“列表形式”意味着将程序及其参数指定为单独的值。单值表单在两个版本上运行:
open my $fh, '|-', 'perl -v' or die "$!\n";
关于perl - Perl 中的“不能使用未定义的值作为文件句柄引用”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4202196/