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

When I do need to worry about '0', I generally stick with

if (defined $x and $x ne '')

Now I'm wondering if there's any particular advantage of using "length($x)" over "$x ne ''"?

If $x is a sub parameter and both '0' and 'undef' are acceptable input, then I sanitize it right up front so I don't have to worry about undefined warnings later in the code when I start using/testing with it.

my $x = shift; $x = '' unless defined $x;