If my Perl program uses Perl modules, how will it determine where to find the file containing the module code?
For example, if the program contains:
According to the perlfunc documentation on use:
use Module LIST
Imports some semantics into the current package from the named module, generally by aliasing certain subroutine or variable names into your package. It is exactly equivalent to
BEGIN { require Module; Module->import( LIST ); }
except that Module must be a bareword.
So require
does the heavy lifting, and the require documentation provides
If EXPR is a bareword, the require assumes a
".pm"
extension and replaces"::"
with"/"
in the filename for you, to make it easy to load standard modules. This form of loading of modules does not risk altering your namespace.In other words, if you try this:
require Foo::Bar; # a splendid bareword
The require function will actually look for the
"Foo/Bar.pm"
file in the directories specified in the@INC
array.