In my code I frequently have to write conditions like this:
if (defined $string and $string ne "") { ..... }
What I really want is to check if the string is not entirely empty. I would like to be able to do something like if ($string) but this would exclude "0".
So I hope that there is a shorter and nicer way to do this. For now I have been using a utility strempty subroutine which runs that check but I doubt it's idiomatic.
In my own code I try to have it so that empty strings are simply undef, where applicable, but sometimes it can't be helped and external modules don't follow this rule hence why I have to write these conditions.
In reply to Checking string emptiness by dave93
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |