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.
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 } );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With