title: How do I initialize values in a hash without a loop?
body: <p>I am trying to figure out a way to initialize a hash without having to go through a loop. I was hoping to use slices for that, but it doesn't seem to produce the expected results.</p>
  
  <p>Consider the following code:</p>
  
  <pre><code>#!/usr/bin/perl
  use Data::Dumper;
  
  my %hash = ();
  $hash{currency_symbol} = 'BRL';
  $hash{currency_name} = 'Real';
  print Dumper(%hash);
  </code></pre>
  
  <p>This does work as expect and produce the following output:</p>
  
  <pre><code>$VAR1 = 'currency_symbol';
  $VAR2 = 'BRL';
  $VAR3 = 'currency_name';
  $VAR4 = 'Real';
  </code></pre>
  
  <p>When I try to use slices as follows, it doesn't work:</p>
  
  <pre><code>#!/usr/bin/perl
  use Data::Dumper;
  
  my %hash = ();
  my @fields = ('currency_symbol', 'currency_name');
  my @array = ('BRL','Real');
  @hash{@array} = @fields x @array;
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>$VAR1 = 'currency_symbol';
  $VAR2 = '22';
  $VAR3 = 'currency_name';
  $VAR4 = undef;
  </code></pre>
  
  <p>There is obviously something wrong.</p>
  
  <p>So my question would be: what is the most elegant way to initialize a hash given two arrays (the keys and the values)?</p>