How do I set a list of scalars from a perl hash?
use strict;
my $my_hash = { field1=>'val1', field2=>'val2', field3=>'val3', };
my ($field1,$field2,$field3) = %{$my_hash}{qw(field1 field2 field3)};
print "field1=$field1\nfield2=$field2\nfield3=$field3\n";
You’re looking for a hash slice which in your case would look like this:
or like this:
If we simplify things so that you’re working with a straight hash rather than hash-ref, we can remove some of the noise and the syntax will look a bit clearer:
Then we can get to your
$my_hashhash-ref version by replacing the hash with a hash-ref in the usual way.