title: Why should you NOT return an array ref?
body: <p>In the question <a href="https://stackoverflow.com/questions/546175/is-returning-a-whole-array-from-a-perl-subroutine-inefficient">"Is returning a whole array from a Perl subroutine inefficient"</a> two people recommend against optimizing if there is no need for it.  As a general rule, optimizing can add complexity, and if it's not needed, simple is better.  But in this specific case, returning an array versus an array ref, I don't see that there's any added complexity, and I think consistency in the interface design would be more important.  Consequently, I almost always do something like:</p>
  
  <pre><code>sub foo
  {
     my($result) = [];
  
     #....build up the result array ref
  
     $result;
  }
  </code></pre>
  
  <p>Is there a reason I should not do this, even for small results?</p>