什么是@l in perl?

前端之家收集整理的这篇文章主要介绍了什么是@l in perl?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我遇到了这个,期待它是$@的拼写错误
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中列出

由于输出显示在…中,似乎这是perl的异常处理中的一些内容.

解决方法@H_403_17@
@ $在Perl中没有任何意义.它的存在是因为$$存在(对于每个特殊变量“sigil-char”,所有其他“another_sigil-char”变量都存在).因此,warn没有任何参数 – 你可以通过使用just war来验证; – 你会得到相同的输出.

现在,让我们阅读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 to die.

$@包含eval中的异常,因此预期会出现这种情况.

原文链接:https://www.f2er.com/Perl/172048.html

猜你在找的Perl相关文章