Just another Perl shrine | |
PerlMonks |
Re: The Law of Inconsistent Assumptionsby ihb (Deacon) |
on Oct 20, 2004 at 15:30 UTC ( [id://400894]=note: print w/replies, xml ) | Need Help?? |
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!
In Section
Meditations
|
|