Indeed, based on the code you show, you should not be able to get the warning you show without also getting your "no HOST defined ..." message. Now, there are (unlikely) ways I can imagine arranging that to happen: 1) have STDOUT going to /dev/null but not STDERR; 2) override printf() with something that changes $_[1]; etc.

My guess is that a more likely explanation is that this isn't the exact code that you are dealing with and your translation from the real code to this post omitted the real cause.

BTW, I disagree with most of the other replies offered so far. Autovivification doesn't explain your problem. I think using exists is a worse idea (only use exists when you have a separate useful meaning for "exists but not defined", which is almost never the case, and should almost never be the case), and suggesting that you change the flow just seems to be missing the point that you are trying to figure out how you got the warning in question.

- tye        


In reply to Re: if not defined question (indeed) by tye
in thread if not defined question by Anonymous Monk

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.