title: Count Perl array size
body: <p>I'm trying to print out the size of my array. I've followed a few other questions like this one on Stack Overflow. However, I never get the result I want.</p>
  <p>All I wish for in this example is for the value of 3 to be printed as I have three indexes. All I get, from both print methods is 0.</p>
  <pre><code>my @arr;
  
  $arr{1} = 1;
  $arr{2} = 2;
  $arr{3} = 3;
  
  my $size = @arr;
  
  print $size; # Prints 0
  
  print scalar @arr; # Prints 0
  </code></pre>
  <p>What am I doing wrong, and how do I get the total size of an array when declared <em>and</em> populated this way?</p>