if( $hash_ref and ref( $hash_ref ) and ref( $hash_ref ) eq 'HASH' and keys %$hash_ref ){ #... }