in reply to testing defined($x) && length($x)

The more concise way is to not write use warnings; to begin with, and then:
if(''ne$x) {...}