use strict; use warnings; my @keys = qw( a c ); my %hash = ( a => 1, b => 2, c => 3, d => 4 ); # typical use - no problem # @hash{a,c} is like $hash{a}, $hash{c} print join( ' ', @hash{@keys} ), "\n"; # 1, 3 my %hoh = ( a => { a => 'a1', b => 'a2', c => 'a3', d => 'a4' }, b => { a => 'b1', b => 'b2', c => 'b3', d => 'b4' }, c => { a => 'c1', b => 'c2', c => 'c3', d => 'c4' }, d => { a => 'd1', b => 'd2', c => 'd3', d => 'd4' } ); # typical use expanded to a %HoH - no problem # @{ $hoh{b} }{a, c} is like $hoh{b}{a}, $hoh{b}{c} print join( ' ', @{ $hoh{b} }{@keys} ), "\n"; # b1, b3 # now I want to slice across the first key instead of the second # want something like $hoh{a}{d}, $hoh{c}{d} print join( ' ', @hoh{@keys}{d} ), "\n"; # syntax error # I tried dereferencing the list of hashrefs, but only # the last ref in the list was used ($hoh{c}) print join( ' ', @{ @hoh{@keys} }{d} ), "\n"; # c4 # do I have to resort to this? print join( ' ', map{ $_->{d} } @hoh{@keys} ), "\n"; # a4 c4