我遇到了这个,希望它是 $@
的拼写错误:
use strict;
use warnings;
eval {
my $error = Not::Here->new();
};
warn @$;
令我惊讶的是它输出了这个:
Can't locate object method "new" via package "Not::Here" (perhaps you forgot to load "Not::Here"?) at dollar_array.pl line 6. ...caught at dollar_array.pl line 9.
我找不到有关
@$
的任何信息,并且它没有在 perlvar 上列出,也不在 eval由于输出显示
caught at ...
,看来这是perl的异常处理中的东西。
最佳答案
@$
在 Perl 中(还)没有意义。它的存在是因为 $$
存在(对于每个特殊变量“sigil-char”,所有其他“another_sigil-char”变量都存在)。因此,warn
没有参数 - 您可以仅使用 warn;
来验证这一点- 你会得到相同的输出。
现在,让我们阅读 warn 的文档:
If the output is empty and
$@
already contains a value (typically from a previous eval) that value is used after appending"\t...caught"
to$@
. This is useful for staying almost, but not entirely similar todie
.
$@
包含来自 eval
的异常,所以行为是预期的。
关于perl - perl 中的@$ 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35955802/