1.2. Modules and Packages

Packages are the perl terminology for namespaces. Namespaces enable the programmer to declare several functions or variables with the same name, and use all of them in the same code, as long as each one was declared in a different namespace. By using namespaces wisely, a programmer can be more certain his code will not clash with code from another developer. Moreover, packages are the basis for Perl's objects system.

Modules are files containing Perl code which can be loaded by programs or other modules. They allow the programmer to declare various functions in various packages (usually below the namespace that corresponds to the package name). Modules facilitate code reuse as the same module can be used by several modules and by several distinct programs.


Written by Shlomi Fish