title: How do I use Perl keys() from a function return value?
body: <p>I know about the Perl <code>keys()</code> function and would like to use it on a hash I have, but don't see any reason to set a variable to it. Let me explain in code two ways:</p>
  
  <p>Normal:</p>
  
  <pre><code>my %hash = ReturnsHash();
  foreach (keys(%hash)) {
      ...code...
  }
  </code></pre>
  
  <p>The way I'd like:</p>
  
  <pre><code>foreach (keys(ReturnsHash())) {
      ...code...
  }
  </code></pre>
  
  <p>With the second way I get this error message(<code>Type of arg 1 to keys must be hash or array (not subroutine entry)</code>) Is the second way possible? If so how?</p>