I expected an error in Something.pm, for calling Foo::foo, when the package "Foo" was not used in package Something.Perl does not keep track of which modules use which other modules. Packages and the subroutines and variables that are in them are global. Once Foo.pm is loaded, Foo::foo() is available everywhere. (use does do an implicit call to the used module's import() method, if it exists, and that import() method can know and record in some fashion which module is doing the use and which module is used; this is usually only used for the used module to export functions into the using package's namespace.)
No, it's not good practice; modules are supposed to help modularize code, and Something shouldn't be relying on (possibly subject to change) internal details of Bar such as what modules it loads. If you are referencing Foo:: from Something.pm, Something.pm should also use Foo to ensure that it is loaded.
In reply to Re: use enlightenment
by ysth
in thread use enlightenment
by InfiniteLoop
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |