I think I got too distracted by the way I was using undef inside if statement -- which is evaluating a variable or expression in boolean context -- and the fact that the expression is a test for numeric equality --

 if ( $possibly_undefined_val_here == 0 )

... because I've routinely used and understood something like  if ( $possibly_undefined_val_here ) to evaluate to "falsey" when the variable is undefined. I hadn't thought about it evaluating to 0, such that the resulting 0 == 0 in the boolean test becomes true, but of course it is.

But I also see that basically I got balled up in seeing that what I wanted was to have a flag that said "OK, we're in production mode because we have a truthy value, so let's roll" rather than one that said "OK, let's not roll if we're in development mode, so check to see whether we have a truthy value as to that, and, in order to be sure we remembered the issue, let's check to see whether we explicitly set the development mode flag to be the digit one or the digit 0."

I'm afraid this kind of complicated, inverted thinking gets in my way a lot. How elegant and direct is the logic of testing for the truth of a production mode flag, like testing to be sure a link in a chain is in place.

Really appreciate this information!


In reply to Re: Surprising result when using undef by davebaker
in thread Surprising result when using undef by davebaker

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.