Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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

  • Comment on Re: How come undef eq '' ??
    Select or Download Code

    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 meditating upon the Monastery: (7)
    As of 2015-11-28 19:32 GMT
    Find Nodes?
      Voting Booth?

      What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

      Results (744 votes), past polls