Loading ...
Sorry, an error occurred while loading the content.

inconsistent hash or array result

Expand Messages
  • Jo Rhett
    I m having a bit of trouble where I m continually having to check if the result is an array or not to deal with it. Is there some way to always get an array,
    Message 1 of 1 , Apr 30, 2010
    • 0 Attachment
      I'm having a bit of trouble where I'm continually having to check if the result is an array or not to deal with it. Is there some way to always get an array, even if a single instance was returned?

      my $result = $som->valueof( '//result' );
      if( ref( $result->{'items'} ) eq 'ARRAY' ) {
      @items = @{ $result->{'items'} };
      }
      else {
      push( @items, $result->{'items'} );
      }

      foreach my $item ( @items ) {
      ....etc

      --
      Jo Rhett
      Net Consonance : consonant endings by net philanthropy, open source and other randomness
    Your message has been successfully submitted and would be delivered to recipients shortly.