The previous example correctly sends a warning based on the assumption that the name main::fee should appear at least twice in a single script.

That statement is a bit too vague and I'll explain why below.

The previous example sends a spurious warning message because the former assumption breaks down

It's only spurious if it is based on the assumption you say it's based on, but as I'll come to, it's not necessarily based on that assumption.

incomplete assumptions about what constitutes a "single script"

I neither agree or disagree, but I more disagree than I agree. I'd stretch as far as saying that you may have an incomplete assumption of what the warning means, and that's why you think it breaks down and you think a spurious warning is emitted. What the warning really means, but doesn't clearly say, is 'Name "main::fee" used (i.e. seen) once (at compile-time)'. It's got nothing to do with where the variable is seen, but when.

Your program is one thing during compile-time. Your program can be another during run-time and can change infinately many times during run-time. The warning is looking at what your program is during compile-time. If you put a BEGIN block around your require() the problem would've been solved and the warning goes away, as the variable is now seen more than once during compile-time. The problem is no different from doing eval '$main::fee = 0xfee'. Perl has no way of knowing that you use that you use $main::fee since the usage of $main::fee is not a part of your program yet.

ihb

See perltoc if you don't know which perldoc to read!
Read argumentation in its context!


In reply to Re: The Law of Inconsistent Assumptions by ihb
in thread The Law of Inconsistent Assumptions by dimar

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.