Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: How come undef eq '' ??

by LanX (Chancellor)
on Jan 30, 2013 at 15:49 UTC ( #1016089=note: print w/replies, xml ) Need Help??

in reply to How come undef eq '' ??

For good reasons operators in Perl do type conversions!

  • ==, + - *   and so on do numification so undef is considered 0

  • eq, . and so on do stringification so undef is considered empty string "".

    Anyway using warnings you'll often get "Use of uninitialized value" messages.

    I do not understand what your intentions are, but if you wanna test for undef use the designated functions defined or //


    Equality Operators in perlop

           Binary "==" returns true if the left argument is numerically equal to
           the right argument.
           Binary "eq" returns true if the left argument is stringwise equal to
           the right argument.

    Cheers Rolf

  • Log In?

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: note [id://1016089]
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (5)
    As of 2016-10-22 04:05 GMT
    Find Nodes?
      Voting Booth?
      How many different varieties (color, size, etc) of socks do you have in your sock drawer?

      Results (292 votes). Check out past polls.