I read O'Reilly Perl objects, links and modules, or rather a section on modules. It states that when using use Some::Module
you can specify an import list. From his explanation, it seems that the only advantage of using this list is to maintain a clean namespace. In other words, if you have a subroutine some_sub
in your package main
, and the loaded module has sub with the same name, your subroutine will be overridden. However, if you specify an import list and leave some_sub
from this list, you will not have this conflict. Then you can run some_sub from the module announcing it as follows: Some::Module::some_sub
.
Is there any other advantage than that described above? I ask about this because in some cases you load modules with a lot of functionality, although you are only interested in some of its methods. At first I thought that by specifying an import list, you only loaded these methods, and did not inflate the memory with methods that you would not use in any case. However, from the above explanation this is not so. Can you selectively save resources by only loading parts of the module? Or is Perl smart enough to do this at compilation without the need for programmer intervention?
source
share