title: not able to access hash of hash of array values
body: <p>I have written the following code in Perl. The code is reading a pdb file and getting some values. Ignore the top part of the code,where everything is working perfect.
  Problem is in the sub-routine part, where I try to store arrays in the hash3 with model as key another key position
  the array values can be accessed inside the if condition using this :</p>
  
  <p>$hash3{$model}{$coordinates}[1]. </p>
  
  <p>but when I go out of all foreach loop and try to access the elements I only get one value.
  Please look at the end foreach loop and tell me is it the wrong way to access the hash values.</p>
  
  <p>The pdb file I am using can be downloaded from this link <a href="http://www.rcsb.org/pdb/download/downloadFile.do?fileFormat=pdb&amp;compression=NO&amp;structureId=1NZS" rel="nofollow">http://www.rcsb.org/pdb/download/downloadFile.do?fileFormat=pdb&amp;compression=NO&amp;structureId=1NZS</a></p>
  
  <pre><code>#!/usr/bin/perl
  open(IN,$ARGV[0]);
  
  my @phosphosites;
  my $model=1;
  my %hash3;
  while(&lt;IN&gt;)
    {
      #findmod(@line);
      #finddist;
      #findfreq;
      if((/^MODRES/) &amp;&amp; (/PHOSPHO/))
        {
          @line=split;
          push(@phosphosites, $line[2]);
          #print "$line[4]";
        }
      foreach $elements (@phosphosites){
        if(/^HETATM\s+\d+\s+CA\s+$i/)
          {
            @line1=split;
            #print "$line1[5]";
            #print "$line1[6] $line1[7] $line1[8]\n";
            push(@phosphositesnum, $line1[5]);
          }
      }
      $pos=$line1[5];
      #findspatial(\@line,\@line1);
    }
  
  my @ori_data=removeDuplicates(@phosphositesnum);
  sub removeDuplicates {
    my %seen = ();
    my @vals = ();
  
    foreach my $i (@_) {
      unless ($seen{$i}) {
        push @vals, $i;
        $seen{$i} = 1;
      }
    }
  
    return @vals;
  }
  
  $a=(@phosphosites);
  print "$a\n";
  print "@phosphosites\n";
  print "@ori_data\n";
  
  close(IN);
  
  open(IN1,$ARGV[0]);
  my (@data)=&lt;IN1&gt;;
  spatial(\@ori_data);
  sub spatial {
  
    my @spatial_array1=@{$_[0]};
  
    foreach $coordinates(@spatial_array1)
      {
        $model=1;
        {foreach $data1(@data){
  
  
  
          if($data1=~ m/^HETATM\s+\d+\s+CA\s+[A-Z]*\s+[A-Z]*\s+$coordinates/)
            {
              @cordivals=split(/\s+/,$data1);
              push @{ $sphash{$model} },[$cordivals[6], $cordivals[7], $cordivals[8]];
              $hash3{$model}{$coordinates}= \@cordivals;
              #print "$model $coordinates $hash3{$model}{$coordinates}[6] $hash3{$model}{$coordinates}[7] $hash3{$model}{$coordinates}[8]\n";
              #print "$model $sphash{$model}[$i][0] $sphash{$model}[$i][1] $sphash{$model}[$i][2]\n";
  
            }
  
          elsif($data1=~ m/^ENDMDL/)
            {
              $model++;
            }
          #print "$model $coordinates $hash3{$model}{$coordinates}[6] $hash3{$model}{$coordinates}[7] $hash3{$model}{$coordinates}[8]\n";
  
  
        }
       }
      }
  
      #foreach $z1 (sort keys %hash3)
      #  {
      #    foreach $z2(@spatial_array1){
      #      print "$z1 $z2";
      #      print "$hash3{$z1}{$z2}[6]\n";
      #      print "$z2\n";
      #    }
      #  }
  }
  </code></pre>
  
  <p>After using the Data::Dumper option it is giving me this kind of output</p>
  
  <pre><code>$VAR1 = {
        '11' =&gt; {
                  '334' =&gt; [
                             'HETATM',
                             '115',
                             'CA',
                             'SEP',
                             'A',
                             '343',
                             '-0.201',
                             '-2.884',
                             '1.022',
                             '1.00',
                             '99.99',
                             'C'
                           ],
  
                  '342' =&gt; $VAR1-&gt;{'11'}{'334'},
  
                  '338' =&gt; $VAR1-&gt;{'11'}{'334'},
  
                  '335' =&gt; $VAR1-&gt;{'11'}{'334'},
                  '340' =&gt; $VAR1-&gt;{'11'}{'334'},
  
                  '343' =&gt; $VAR1-&gt;{'11'}{'334'},
  
                  '336' =&gt; $VAR1-&gt;{'11'}{'334'}
                },
  
        '7' =&gt; {
  
                 '334' =&gt; $VAR1-&gt;{'11'}{'334'},
  
                 '342' =&gt; $VAR1-&gt;{'11'}{'334'},
  
                 '338' =&gt; $VAR1-&gt;{'11'}{'334'},
  
                 '335' =&gt; $VAR1-&gt;{'11'}{'334'},
  
                 '340' =&gt; $VAR1-&gt;{'11'}{'334'},
  
                 '343' =&gt; $VAR1-&gt;{'11'}{'334'},
  
                 '336' =&gt; $VAR1-&gt;{'11'}{'334'}
  
               },
  
        '2' =&gt; {
  
                 '334' =&gt; $VAR1-&gt;{'11'}{'334'},
  
                 '342' =&gt; $VAR1-&gt;{'11'}{'334'},
                 ...
  </code></pre>