Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^2: Check Variables for NULL

by Joost (Canon)
on Feb 07, 2007 at 21:22 UTC ( #598889=note: print w/replies, xml ) Need Help??

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.

Replies are listed 'Best First'.
Re^3: Check Variables for NULL
by Trihedralguy (Pilgrim) on Feb 07, 2007 at 21:45 UTC
    Your awesome!!
    Thanks so much for your help, for some reason I just forgot about "EQ and NE"
      for some reason I just forgot about "EQ and NE"
      It would be good to keep brush up your knowledge in perl.
      Note that uppercase "EQ" and "NE" are deprecated and might go away sometime. Use "eq" and "ne" instead.
        They have gone away sometime between 5.003 and 5.8, not sure exactly when, though. I know this because it's bitten me in the ass during a server migration recently.

        Systems development is like banging your head against a wall...
        It's usually very painful, but if you're persistent, you'll get through it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://598889]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2018-07-21 02:16 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (443 votes). Check out past polls.