Main Navigation

Content

Perl Modules and Packages

Learn Perl Now!
And get a job doing Perl.

Introduction

Perl Modules and Perl Packages are two closely related - but independent - subjects that enable writing more reusable and more modular code. Furthermore, packages are the basis of Perl's Object Oriented Programming.

Modules

Modules allow you to put some reusable Perl code into its own file, which can then be loaded from any Perl program, or from a different module. One can then call subroutines from these modules or even import them into the current scope.

Packages

Packages are known as namespaces in other languages, and are Perl's way of making sure not all symbols live in the same place. One can create an arbitrary number of packages in Perl and they can be nested. It is a good idea that the package and module names will correspond to avoid confusion.

Tutorials

Beginning Perl

Chapter 10 of this of this book for Perl beginners (including absolute beginners) covers modules. This book was written by one of the foremost Perl experts.

Perl for Perl Newbies Series

The third talk in the series explains modules and packages in detail, although from a very low level and how they work behind the scenes.

Modern Perl (the Book)

Covers modules.

Perldoc Tutorials

These are the Perldoc OOP tutorials that ship with Perl:

CPAN

CPAN stands for the Comprehensive Perl Archive Network and is a repository of many re-usable, open-source, modules that can be used in one's Perl code. See the link for more information.

Useful Technologies

Sub-Exporter

A more powerful and easier to use alternative to the built-in Exporter.pm module.

Share/Bookmark

Sidebar

Footer