我有我的主要 Perl 脚本,其中包含
my $System = {
Path =>
{
root => 'hello'
}
}
print $System->{'Path'}->{'root'}; # prints 'hello'
如何$System->{'Path'}->{'root'}
从外部模块访问变量?
我知道我可以使用main::
命名空间来检索全局变量,例如$main::x
,但以下不起作用$main::System->{'Path'}->{'root'}
。
我也尝试了不同的语法,但我无法得到它。
我究竟做错了什么?