First, when you expect to get a list from a hash snippet, use @ sigil first. % is pointless here.
Secondly, you should understand that the value of $hash{$document} not a hash or an array. This is a reference to a hash OR to an array.
With all of this in mind, you can use something like this:
@{ $hash{$document} }{ @list };
... so you are looking for the value of $hash{$document} , and then use the hash fragment above it. For instance:
my %hash = ( 'one' => { 'first' => 1, 'second' => 2, }, 'two' => { 'third' => 3, 'fourth' => 4, } ); my $key = 'one'; my @list = ('first', 'second'); print $_, "\n" for @{ $hash{$key} }{@list};
source share