in reply to Assigning Null to a variable

Perl does not have a value to correspond to the SQL notion of NULL. It only has undef. It does not have a built-in concept of "I know what the value is, and the value is: that it is known that it has no value at all."

Replies are listed 'Best First'.
Re^2: Assigning Null to a variable
by AnomalousMonk (Archbishop) on Jul 02, 2012 at 15:34 UTC

    I don't know enough about SQL to know how its  NULL compares to Perl's undef, but it strikes me that "I know what the value is, and the value is: that it is known that it has no value at all" is actually a pretty good (Update: well, on second thought, perhaps just a bit wordy) explanation of our friend undef!

      "I know what the value is, and the value is: that it is known that it has no value at all" is actually a pretty good explanation of our friend undef!

      ... and that's why DBI maps SQL's NULL to undef and vice versa.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^2: Assigning Null to a variable
by cavac (Prior) on Jul 02, 2012 at 15:10 UTC

    You could still use it that way in arrays.

    For hashes there is "exists" vs. "defined", see perldoc -f exists. If haven't tested it now (working from memory and POD), but this looks like it fits the bill.

    Sorry for any bad spelling, broken formatting and missing code examples. During a slight disagreement with my bicycle (which i lost), i broke my left forearm near the elbow. I'm doing the best i can here...