title: How do I load a file into a Perl hash?
body: <p>Given the following file:</p>
  
  <pre><code>department=value1
  location=valueA
  location=valueB
  department=value2
  </code></pre>
  
  <p>I use the following to load the file into a Perl hash:</p>
  
  <pre><code>use File::Slurp;
  use Data::Dumper;
  my %hash = map {
     s/#.*//;
     s/^\s+//;
     s/\s+$//;
     m/(.*?)\s*=\s*(.*)/;
  } read_file($file);
  print Dumper(\%hash);
  </code></pre>
  
  <p>The result, however, is as follows:</p>
  
  <pre><code>$VAR1 = {
            'location' =&gt; 'valueB',
            'department' =&gt; 'value2'
          };
  </code></pre>
  
  <p>How can I load the above file into a hash with, say,</p>
  
  <pre><code>$VAR1 = {
            'location' =&gt; 'valueA,valueB',
            'department' =&gt; 'value1,value2'
          };
  </code></pre>
  
  <p>Thanks.</p>