Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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"
    Duh!
      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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2018-01-17 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (194 votes). Check out past polls.

    Notices?