Quantcast
Channel: In Perl, how can I concisely check if a $variable is defined and contains a non zero length string? - Stack Overflow
Viewing all articles
Browse latest Browse all 10

In Perl, how can I concisely check if a $variable is defined and contains a non zero length string?

$
0
0

I currently use the following Perl to check if a variable is defined and contains text. I have to check defined first to avoid an 'uninitialized value' warning:

if (defined $name && length $name > 0) {    # do something with $name}

Is there a better (presumably more concise) way to write this?


Viewing all articles
Browse latest Browse all 10

Trending Articles