Chapter 13. Packages and Modules

import module [ list ]

Usually imports subroutines and variables from module into the current package. import is not a built-in, but an ordinary class method that may be inherited from UNIVERSAL.

no module [ list ]

At compile time, requires the module and calls its unimport method on list. See use on the next page.

package [ namespace ]

Designates the remainder of the current block or file as a package with a namespace. Omitting namespace is deprecated.

require version

Requires Perl to be at least this version. version can be numeric like 5.005 or 5.008001, or a v-string like v5.8.1.

require expr

If expr is numeric, behaves like require version. Otherwise expr must be the name of a file that is included from the Perl library. Does not include more than once, and yields a fatal error if the file does not evaluate to true. If expr is a bare word, assumes extension .pm for the name of the file.

unimport module [ list ]

Usually cancels the effects of a previous import or use. Like import, unimport is not a built-in, but an ordinary class method.

use version

Requires Perl to be at least this version. version can be numeric like 5.005 or 5.008001, or a v-string like v5.8.0 or 5.8.1.

use module [ version ] [ list ]

At compile time, requires the module, optionally verifies the version, and calls its import method on list. Normally used to import a list of variables and subroutines from the named module into the current package.

perlmod.

Get Perl Pocket Reference, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.