title: Perl - anonymous hashmaps and arrays - few questions
body: <p>Hello I am learning perl and I will post several assumptions here. So please feel free to commenting and correcting me if I am wrong somewhere.</p>
  
  <ol>
  <li><p>Creating hash are done (among several another ways) by: </p>
  
  <pre><code>%numbers = qw(one 1 two 2);
  </code></pre></li>
  <li><p>Creating array are done by following:</p>
  
  <pre><code>@array = qw(one two);
  </code></pre></li>
  <li><p>Above constructions represents "non anonymous" types. The main difference between non anonymous and anonymous types is that named types have a name which I can refer to. If I want to create anonymous types I need to change parenthesis <code>()</code> for square brackets <code>[]</code> in arrays, or for braces <code>{}</code> in hashes. Hash of hashes in other words are hash of references to other hashes. Thus I need to use <code>{}</code> in nested hash and not classic hash <code>()</code>.</p>
  
  <pre><code>%HoH = (
      flintstones =&gt; {
          husband   =&gt; "fred",
          pal       =&gt; "barney",
      },
      jetsons =&gt; {
          husband   =&gt; "george",
          wife      =&gt; "jane",
          "his boy" =&gt; "elroy",  # quotes needed on key.
      },
      simpsons =&gt; {
          husband   =&gt; "homer",
          wife      =&gt; "marge",
          kid       =&gt; "bart",
      },
  );
  </code></pre></li>
  <li><p>The same situation applies for multi dimensional arrays. Multi dimensional array is an array containing refernces to another array, thus [] needs to be used instead ().</p>
  
  <pre><code>@array_of_arrays =  ( [ "one", "two", "three" ],
                        [  4,   5,  6,  7  ],
                        [ "alpha", "beta" ]
                      );
  </code></pre></li>
  <li><p>If I had "non anonymous" hashes containing each family members (flinstones, jetsons, simpsons) which construction should I use for creating <code>%HOH</code>?</p>
  
  <pre><code>$HOH{flinstones} = {%flinstones};
  </code></pre>
  
  <p>or</p>
  
  <pre><code>$HOH{flinstones} = \%flinstones;
  </code></pre>
  
  <p>I am assuming that <code>\%flinstones</code> is simply assigning reference to <code>$HOH{flinstones}</code>, this means that whatever I do to <code>%flinstones</code> will influence the <code>$HOH{flinstones}</code> because it simply contains reference to it. On the other hand <code>{%flinstones}</code> is something like re-casting of "non anonymous" hash to "anonymous" hash. This has effect that <code>%flinstones</code> can be later modified or even deleted and it will not affect the <code>$HOH{flinstones}</code> because there is reference to anonymous hash.</p></li>
  <li><p>What will happen with variable in loop? When <code>my $variable;</code> is issued inside loop it overwrites old one or creates new, or it is the same variable, or what happens here?</p>
  
  <pre><code>for($i=0;$i&lt;4;$i++){
    my $variable=$i;
    print $variable
  }
  </code></pre></li>
  </ol>