http://www.perlmonks.org?node_id=598889


in reply to Re: Check Variables for NULL
in thread Check Variables for NULL

Well the answer depends on how you get the value from the "box". Most UI components return empty input as an empty string, but some might return undef instead.

# let's say you've got the user input in $input.. if (defined($input) && $input ne "") { # input is defined and not empty } else { print "input wasn't filled in\n"; }
Note that compare strings with eq and ne instead of == and != since == and != coerce their arguments to numbers.

See equality operators and defined in the documentation.