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

Re: How come undef eq '' ??

by LanX (Canon)
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 //

    EDIT

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

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

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (4)
    As of 2014-07-24 04:41 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (157 votes), past polls