Skip to Main Content
Perl Pocket Reference, 5th Edition
book

Perl Pocket Reference, 5th Edition

by Johan Vromans
July 2011
Intermediate to advanced content levelIntermediate to advanced
104 pages
2h 14m
English
O'Reilly Media, Inc.
Content preview from Perl Pocket Reference, 5th Edition

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl Testing: A Developer's Notebook

Perl Testing: A Developer's Notebook

Ian Langworth, Chromatic
Perl Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe

Publisher Resources

ISBN: 9781449311186Errata Page