title: perl parsing and assigning multiple values to hash key using array
body: <p>I have  files that I'm trying to parse and build a hash and lookup from a third file. File format :</p>
  
  <p>File 1: </p>
  
  <pre><code>ID2
  ID4
  </code></pre>
  
  <p>File 2: </p>
  
  <pre><code>x1 y1 z1 ID1
  x2 y2 z2 ID2
  x3 y3 z3 ID2
  x4 y4 z4 ID4
  </code></pre>
  
  <p>File 3: </p>
  
  <pre><code>a1 b1
  a2 b2
  a3 b3
  </code></pre>
  
  <p>What I'm trying to do : </p>
  
  <p>For all those IDs in File1, look up x and y coordinate using ID field in File2 , and see if 'a' in File3 lies between x and y.</p>
  
  <p>What I have thought so far : </p>
  
  <ol>
  <li>Take file 2; parse it into a hash using ID as the key </li>
  <li>Take file 1; if ID exists in file 2; open file 3 and check coordinates ranges for 'a'
  and print it</li>
  </ol>
  
  <p>How far have I executed? 
  Not too far. I am trying to read File 2 and parse all element in a hash, but I'm stuck: </p>
  
  <pre><code>while (&lt;FILE&gt;){
      chomp $_;
      my $line = $_;
      my @arr  = split ("\t", $line);
      my $id = $arr[3];
  
      if (exists ($hash{$id})) {
          my $x = $arr[0];
          my $y  = $arr[1];
          my $z   = $arr[2];
          push @{$hash{$id}{'x'}, $x;
          push @{$hash{$id}{'y'}, $y;
          push @{$hash{$id}{'y'}, $y;
      } else {
          $hash{'id'} = $id;
          $hash{$id}{'x'} = $arr[0];   
          $hash{$id}{'y'} = $arr[1];
          $hash{$id}{'z'} = $arr[2];
      }
  }
  print Dumper %hash;
  close FILE;
  </code></pre>
  
  <p>But of course, I'm doing something wrong here</p>