title: How can I iterate over a Perl array reference?
body: <p>I have an array that is a member of a structure:</p>
  
  <pre><code>$self-&gt;{myArray} = ["value1", "value2"];
  </code></pre>
  
  <p>And I'm trying to iterate over it using the following code:</p>
  
  <pre><code>my @myArray = $self-&gt;{myArray};
  foreach my $foo (@myArray){
      #Do something with the using $foo
      ...
  }
  </code></pre>
  
  <p>The problem is that the 'foreach' loop is executed only once (when I would expect it to execute twice, since @myArray has two elements: "value1" and "value2").</p>
  
  <p>When I check the @myArray array size, I get that its size is 1. What am I doing wrong in this code?</p>