title: Undefined Array in Perl
body: <p>Is it possible to in some way indicate if an <em>array</em> in Perl is undefined or null?</p>
  <p>I find myself coming across situations where I would like to be able to differentiate between an empty array and one that hasn't been populated yet (or failed to populate for some reason).</p>
  <p>So for instance, with an array reference I can do this:</p>
  <pre><code>my $apples;
  $apples = get_apples();
  
  if(defined $apples){
  
      if(scalar @$apples == 0){
          # We successfully got the list of apples, but there were none
      }
  
      }
      else{
  
          # There was a problem getting the list of apples
  
  }
  </code></pre>
  <p>My only complaint about this is that &quot;my $apples&quot; doesn't tell you that <em>$apples</em> is intended to be an array reference, so <em>@apples</em> would be more specific.</p>
  <p>It doesn't look there is a way to do something with an array explicitly. Is that the case? Will another variable always be required to indicate if the array was successfully populated?</p>
  <p>The following could never be tested for a successful return of apples, right? Or am I missing something neat?</p>
  <pre><code>my @apples;
  (@apples) = get_apples();
  </code></pre>
  <p>I know that <em>get_apples</em> could both return a success and a list to populate the array with, but I'm curious if there is a way to indicate a null or undefined value with just an array.</p>