trying to understand the perldoc description givees me too much of a headache:-

A hash or array element can be true only if it's defined and defined only if it exists, but the reverse doesn't necessarily hold true.

here's a Venn(ish) diagram in beautiful ASCII art that may or may not help, with examples on the side

universe of possible hash elements in Perl +--------------------------------------+ | elements that exist | $hash{element_exis +ts}; # this example: exists, undefined, false | +--------------------------------+ | | | elements that are defined | | $hash{element_defi +ned} = function_def();# this example: exists, defined, unknown false/ +true | | +--------------------------+ | | | | | elements that are true | | | $hash{element_true +} = 1; # this example: exists, defined, true | | +--------------------------+ | | | | | | | | +--------------------------+ | | | | : elements that are false : | | $hash{element_fals +e} = function_false();# this example: exists, defined, false | | : +-------------------+ : | | | | : | false but defined | : | | $hash{element_fals +e_defined} = 0; # this example: exists, defined, false | | : +-------------------+ : | | | +--:--------------------------:--+ | | : : | | +--:--------------------------:--+ | | | : +-------------------+ : | | | | : | false but undef | : | | $hash{element_fals +e_undefined} = undef; # this example: exists, undefined, false | | : +-------------------+ : | | | | +--------------------------+ | | | | elements that are undefined | | $hash{element_unde +fined}; # this example: exists, undefined, false | +--------------------------------+ | +--------------------------------------+

Note that the ASCII art combined with wanting space for labels sometimes implies there is room in the Perl universe for combinations that aren't actually possible: for example, there are no elements that are undefined but not false, because perl coerces undefined to false.


In reply to Re^2: How to Check Hashes for Missing Items when Keys can be Values and vice versa by pryrt
in thread How to Check Hashes for Missing Items when Keys can be Values and vice versa by ozboomer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.