Perl - 在嵌套数组中获取值

Perl - Get value in nested array of arrays

我有一个变量 ($issue),其中包含我需要从中提取单个值 (emailAddress) 的各种值。 $issue(通过Data::Dump)的内容是:

'fields' => {
    'reporter' => {
        'name' => 'jeremywilson',
            'displayName' => 'Jeremy Wilson',
            'key' => '15429',
            'emailAddress' => 'jwilson@syslog.com',
            'timeZone' => 'America/New_York',
            'active' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' )
    },
    'customfield' => [
        {
            'active' => $VAR1->{'fields'}{'reporter'}{'active'},
            'timeZone' => 'America/New_York',
            'emailAddress' => 'mexample@nowhere.com',
            'key' => 'mexample',
            'name' => 'mexample',
            'displayName' => 'Mike Example'
        }
    ],
}

我通过 $issue->{fields}->{'reporter'}->{'emailAddress'} 收到第一封电子邮件,但我如何从 customfield 获取值?

评论包含两个答案

$issue->{fields}->{customfield}[0]->{emailAddress}

更短,但也正确

$issue->{fields}{customfield}[0]{emailAddress}

这些回答了所问的问题,但可能需要对一般答案进行更多说明,例如,当有多个自定义字段时,或者如果自定义字段是可选的,数据将如何表示?