Dereferencing a hash value

hash, perl, reference

Solution

You use the `->` operator:

$e[0]->{"lkj"}

You can do something similar for arrayrefs, and it's even chainable:

my $eref = \@e;
print $eref->[0]->{"lkj"}

As a bonus, you can do all the setup in a single line too by using the `{}` shorthand for arrayrefs:

my @e = ( { lkj => 34 }, { lkj => 66 } );

Problem

This doesn't work: ``` my %y = ("lkj",34); my %i = ("lkj",66); my @e = (\%y, \%i); my $u = ${%{$e[0]}}{"lkj"}; ``` but this does: ``` my %u = %{$e[0]}; print $u{"lkj"}; ``` If I don't feel like typing that extra line what do i do.

Original source