在散列中,我们可以将三个键组合在一起指向一个值吗?

In a hash, can we have three keys combined together that point to one value?

我对下面的散列声明有疑问:

%metadataHash 是一个散列

line 1: $metadataHash->{"name"} = $name;
line 2: $metadataHash->{"type"} = $Type;
line 3: $metadataHash->{"student"}{$file}{"math"} = "/$file";
line 4: $metadataHash->{"student"}{$file}{"phy"} = $phy;
line 5: $metadataHash->{"student"}{$file}{"chem"} = $chem;

在第1行和第2行,很明显keys("name","type")和values($name,$Type).

但是在第 3 行,

$metadataHash->{"fastq"}{$file1}{"read1"}$metadataHash->{"fastq"}->{$file1}->{"read1"} 的 shorthand 语法。

它处理哈希,其中一个值是对另一个哈希的引用。


用演示来解释:

#!/usr/bin/perl

use strict;
use warnings;

my $foo = {};

$foo->{a}{b}{c} = 1;

use Data::Dumper;

print Dumper($foo);

给出:

$VAR1 = {
          'a' => {
                   'b' => {
                            'c' => 1
                          }
                 }
        };