【发布时间】:2021-07-04 22:35:03
【问题描述】:
我想获取 a1 的值,但收到一条错误消息:不能使用未定义的值作为标量引用。
sub new{
_name = [\\@ a1, \\@a2];
}
我的代码:
${self->_name}[0]; //get the pointer a1
${${self->_name}[0]} // get the value a1
【问题讨论】:
-
欢迎来到 SO!很难说出你的代码在这里。见how to format code
-
很多这看起来像不正确/危险的 Perl 语法 - 你放了“use strict;”吗?将您的示例完成为 minimal reproducible example,这将提供您想要询问的确切错误。
-
该代码不会产生您声称的错误,因为它甚至没有编译!
标签: perl reference dereference