O'Reilly logo

Perl Pocket Reference, 5th Edition by Johan Vromans

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 [ version ] [ block ]

Designates the block as a package with a namespace. Without block, applies to the remainder of the current block or file. Sets package variable $VERSION to version, if specified.

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
use pragma

See the section Pragmatic Modules below.

By convention, pragma names start with a lowercase letter.

use module [ version ] [ list ]

At compile time, requires the module, optionally verifies the version, and calls its import method on list.

If list is (), doesn’t call import.

Normally used to import a list of variables and subroutines from ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required