Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 无法理解某些变量_Perl - Fatal编程技术网

Perl 无法理解某些变量

Perl 无法理解某些变量,perl,Perl,我有一个代码行: $data->{nav}->{'current'}->{performance_gross} 我知道$data是标量,nav,performance\u gross是散列键。但是什么是'current'?nav,'current'和performance\u gross是分别计算字符串nav,current和performance\u gross的表达式。这三个字符串用作不同哈希的键 以下各项均相当: $data->{'nav'}->{'curr

我有一个代码行:

$data->{nav}->{'current'}->{performance_gross}

我知道
$data
是标量,
nav
performance\u gross
是散列键。但是什么是
'current'

nav
'current'
performance\u gross
是分别计算字符串
nav
current
performance\u gross
的表达式。这三个字符串用作不同哈希的键

以下各项均相当:

$data->{'nav'}->{'current'}->{'performance_gross'}
$data->{'nav'}{'current'}{'performance_gross'}
$data->{nav}->{current}->{performance_gross}
$data->{nav}{current}{performance_gross}

nav
'current'
performance\u gross
是分别计算字符串
nav
current
performance\u gross
的表达式。这三个字符串用作不同哈希的键

以下各项均相当:

$data->{'nav'}->{'current'}->{'performance_gross'}
$data->{'nav'}{'current'}{'performance_gross'}
$data->{nav}->{current}->{performance_gross}
$data->{nav}{current}{performance_gross}

Perl允许在散列查找中对密钥使用任意表达式:

$hash{ arbitrary($code) . $here }
(结果字符串用作哈希键。)

但是,如果
{
}
之间只有一个简单的标识符,则会自动引用:

$hash{ some_word }
# is equivalent to
$hash{ 'some_word' }

这就是为什么在散列键中经常可以省略引号。但是显式地将字符串文本放在那里仍然有效,这意味着同样的事情。

Perl允许在散列查找中对键使用任意表达式:

$hash{ arbitrary($code) . $here }
(结果字符串用作哈希键。)

但是,如果
{
}
之间只有一个简单的标识符,则会自动引用:

$hash{ some_word }
# is equivalent to
$hash{ 'some_word' }

这就是为什么在散列键中经常可以省略引号。但是显式地将字符串文本放在那里仍然是有效的,这意味着同样的事情。

一个等价的访问将是
$data->{nav}{current}{performance\u gross}
一个等价的访问将是
$data->{nav}{current}{performance\u gross}