if ($x and length($x)) {} # Do something
This should take care of your $x not being defined.
Update: Too early did not think clearly see below. Removed the offending/incorrect text.
In reply to Re: testing defined($x) && length($x)
by Herkum
in thread testing defined($x) && length($x)
by perl5ever
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |