title: perl hash mapping/retrieval issues with split and select columns
body: <p><a href="https://stackoverflow.com/questions/22230747/perl-find-and-replace-multiplehuge-strings-in-one-shot">Perl find and replace multiple(huge) strings in one shot</a></p>
  
  <p>P.S.This question is related to the answer for above question. </p>
  
  <p>When I try to replace this code:</p>
  
  <p><strong>Snippet-1</strong></p>
  
  <pre><code>open my $map_fh, '&lt;', 'map.csv' or die $!;
  my %replace = map { chomp; split /,/ } &lt;$map_fh&gt;;
  close $map_fh;
  </code></pre>
  
  <p>with this code:</p>
  
  <p><strong>Snippet-2</strong></p>
  
  <pre><code>my %replace = map { chomp; (split /,/)[0,1] } &lt;$map_fh&gt;;
  </code></pre>
  
  <p>even though the key exists (as in the dumper), <strong>exists</strong> statement doesn't return the value for the key. </p>
  
  <p>For same input file, it works perfectly with just split alone (Snippet-1) whereas not returning anything when i select specific columns after split(Snippet-2).</p>
  
  <p>Is there some integer/string datatype mess-up happening here?</p>
  
  <p><strong>Input Mapping File</strong></p>
  
  <pre><code>483329,Buffalo
  
  483330,Buffalo
  
  483337,Buffalo
  </code></pre>
  
  <p><strong>Script Output</strong></p>
  
  <pre><code>$VAR1 = {
            '483329' =&gt; 'Buffalo',
            '46546' =&gt; 'Chicago_CW',
            '745679' =&gt; 'W. Washington',
          };
  1 search is ENB 
  2 search is 483329 **expected Buffalo here**
  3 search is 483330 
  4 search is 483337
  </code></pre>
  
  <p><strong>Perl Code</strong></p>
  
  <pre><code>open my $map_fh, '&lt;', $MarketMapFile or die $!;
  
  if ($MapSelection =~ /eNodeBID/i) {
      my %replace = map { chomp; (split /,/)[0,1] } &lt;$map_fh&gt;;
      use Data::Dumper;
      print Dumper(\%replace);
  }
  close $map_fh;
  
  my $csv = Text::CSV-&gt;new({ binary =&gt; 1, auto_diag =&gt; 1, eol =&gt; $/,quote_space =&gt; 0 });
  my $tmpCSVFile = $CSVFile."tmp";
  
  open my $in_fh, '&lt;', $CSVFile or die $!;
  open my $out_fh, '&gt;', $tmpCSVFile or die $!;
  my $cnt=1;
  
  while (my $row = $csv-&gt;getline($in_fh)) {
      my $search = $row-&gt;[5];
      $search =~ s/[^[:print:]]+//g;
      if ($MapSelection =~ /eNodeBID/i) {
          $search =~ s/(...)-(...)-//g;
          $search =~ s/\(M\)//g;
      }       
  
      my $match = (exists $replace{$search}) ? $replace{$search} : undef;
      print "\n$cnt search is $search ";
      if (defined($match)) {
          $match =~ s/[^[:print:]]+//g;
          print "and match is $match";
      }
  
      push @$row, $match;
  
      #print "  match is $match"; 
      $csv-&gt;print($out_fh, $row);
      $cnt++;
  }
  
  # untie %replace;
  close $in_fh;
  close $out_fh;
  </code></pre>