title: odd number of elements in anonymous hash
body: <p>I'm trying to understand this Perl code...</p>
  
  <p>If there is one stream it works, if there are 2 or more streams it warns with odd number of elements in anonymous hash.  It seems to return an array in that case.  How do I add the array elements correctly to @streams?  It appears to add correctly for the HASH case in the if clause. Is the else clause bunk?</p>
  
  <pre><code> my $x = $viewedProjectDataObj-&gt;{streams};
  
      if (ref($x) eq 'HASH') {
          push(@streams, $x-&gt;{id});
      } elsif (ref($x) eq 'ARRAY') {
  
          print "$x\n";
          print "@$x\n";
          my @array = @$x;
          foreach my $obj (@array) {
              print "in $obj\n";
              print Dumper( $obj);
              push(@streams,  ($obj-&gt;{id}) );
          }
      }
  
      print "streamcount " . @streams % 2;
      print Dumper(@streams);
  
  
      my $stream_defect_filter_spec = {
          'streamIdList' =&gt; @streams,
          'includeDefectInstances' =&gt; 'true',
          'includeHistory' =&gt; 'true',
      };
  
      my @streamDefects = $WS-&gt;get_stream_defects($defectProxy, \@cids,             $stream_defect_filter_spec);
      print Dumper(@streamDefects);
  </code></pre>
  
  <p>I'm adding the next lines...</p>
  
  <pre><code>if ($defectSummary-&gt;{owner} eq "Various") {
      foreach (@streamDefects) {
          if (exists($_-&gt;{owner})) {
              $defectSummary-&gt;{owner} = $_-&gt;{owner};
              last;
          }
      }
  }
  
  my $diref = $streamDefects[0]-&gt;{defectInstances};
  if ($diref) {
      my $defectInstance;
      if (ref($diref) eq 'HASH') {
          $defectInstance = $diref;
      } elsif (ref($diref) eq 'ARRAY') {
          $defectInstance = @{$diref}[0];
      } else {
          die "Unable to handle $diref (".ref($diref).")";
      }
  </code></pre>
  
  <p>It now errors with </p>
  
  <p>Web API returned error code S:Server: calling getStreamDefects: No stream found
  for name null.
  $VAR1 = -1;
  me
  Can't use string ("-1") as a HASH ref while "strict refs" in use at xyz-handler.pl line 317.</p>
  
  <p>some Dumper output</p>
  
  <pre><code>$VAR1 = {
        'streamIdList' =&gt; [
                            {
                              'name' =&gt; 'asdfasdfadsfasdfa'
                            },
                            {
                              'name' =&gt; 'cpp-62bad47d63cfb25e76b29a4801c61d8d'
  
                            }
                          ],
        'includeDefectInstances' =&gt; 'true',
        'includeHistory' =&gt; 'true'
      };
  </code></pre>