Perl Programming Help:
Dec 31, 2000, 8:17 PM
I've seen scripts use a file that it came with such as
and in the somefile.pm it has a bunch of pre-defined variables like
and so on. So when I say use somefile.pm does that load the contents of that file into a cache?
Jan 1, 2001, 7:58 AM
The use compile-time directive is like calling require(), but: a) it happens at compile-time, b) it also calls the import() method of the module, if it exists, and c) it only works with modules (files ending in .pm).
It's used like so:
The import() method allows you to access specific parts of the module to be copied into your program, instead of having to access them from the module's namespace. Some modules import things automatically.
use Some::Module; # the file is Some/Module.pm
use Foobar 'blat'; # the file is Foobar.pm
# are like
To learn more about modules, please read perldoc perlmod.
Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author