Perl:将键和值数组转换为哈希值

Wer*_*eit 5 arrays perl hash

我有两个像这样的阵列

my @keys = qw/Key_1 Key_2 Key_3/;
my @values = qw/foo bar more/;
Run Code Online (Sandbox Code Playgroud)

是否有一个简短的方法(即单个函数)来获取这样的哈希而不使用循环?

my %hash_table = ( Key_1 => "foo", Key_2 => "bar", Key_3 => "more" );
Run Code Online (Sandbox Code Playgroud)

我试图使用map功能但没有成功.

Сух*_*й27 17

使用哈希切片,

my %hash_table;
@hash_table{@keys} = @values;
Run Code Online (Sandbox Code Playgroud)

使用地图,

my %hash_table = map { $keys[$_] => $values[$_] } 0 .. $#keys;
Run Code Online (Sandbox Code Playgroud)