if (grep {!ref($_) or $_->tag ne "a"} $td->content_list) { # The element has non-link text } else { # The element only has elements in it }