By saying "But none of those are a one-to-one match with 'NULL'", you both deny a simple answer and leave some information off the table that would be helpful to those coming at this from an SQL perspective.
The simple answer, which is probably "right" for much of the audience is to explain undef and how you test for it. For someone fetching a row of fields out of a database, where some of the field can be NULL, this answer is good enough.
Where this answer goes awry is in SQL comparison semantics. In SQL, you test for the presense of NULL using an "IS NULL" clause, because NULL is never equal to NULL. A frequent source of SQL newbie errors is preparing
SELECT a FROM t WHERE b = ?
and then binding NULL (or undef) to the placeholder. No go. One needs to write
SELECT a FROM t WHERE b IS NULL
Granted, this is a SQL problem and not a Perl problem, but it's lurking there waiting to bite the uninformed. In my opinion, it's worth mentioning whenever any asks about how to do NULL in Perl.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.