title: Looping through an array of hashes in Perl
body: <p>I'm a total Perl newbie, so forgive me if this is really stupid, but I can't figure this out. If I have an array like this:</p>
  
  <pre><code>my @array = (
    {username => 'user1', email => 'user1@email' },
    {username => 'user2', email => 'user2@email' },
    {username => 'user2', email => 'user3@email' }
  );</code></pre>
  
  <p>What's the most simple way to loop through this array? I thought something like this would work:</p>
  
  <pre><code>print "$_{username} : $_{email}\n" foreach (@array);</code></pre>
  
  <p>But it doesn't. I guess I'm too stuck with a PHP mindset where I could just do something like: <pre><code>foreach ($array as $user) { echo "$user['username'] : $user['email']\n"; }</code></pre></p>