Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
> Fair enough, but why does it work and print the value of $PI if I comment out the use of CONST in main entirely (i.e. main's last line)?
Strict has 3 effects, one (subs) is to restrict the use of barewords to only known subs. Constants are implemented as subs and need to be known at compile time. See also "use subs " This doesn't necessarily mean that the sub known at compile time is also the called sub, because resolution happens at run time. (Keep in mind that you can redefine subs dynamically, this will just update the reference in the symbol table) Any sub called with & or trailing () is not a bareword anymore, and not effected by strict. Another effect of strict (vars) is to enforce pre declaration of unqualified variables with my or our. But your variables are fully qualified. And barewords are not variables (under strict).
UpdateIt all becomes much easier if you first understand how Perl works without strict, an why these restrictions need to be done.
Cheers Rolf
In reply to Re^3: Importing constans and variables when "require"ing
by LanX
|
|