Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这不起作用:
my %y = ("lkj",34); my %i = ("lkj",66); my @e = (\%y, \%i); my $u = ${%{$e[0]}}{"lkj"};
但这确实:
my %u = %{$e[0]}; print $u{"lkj"};
如果我不想输入额外的行,我该怎么办。
您使用->运算符:
->
$e[0]->{"lkj"}
你可以为 arrayrefs 做类似的事情,它甚至可以链接:
my $eref = \@e; print $eref->[0]->{"lkj"}
作为奖励,您也可以使用{}arrayrefs 的简写在一行中完成所有设置:
{}
my @e = ( { lkj => 34 }, { lkj => 66 } );