Perl modules


A perl module is a piece of perl code reusable by different programs. It helps keeping your code well organized.

The module structure looks as following.

Example of a simple module:
package Hello;

sub greet {
  return "Hi world!";

use Hello;

print Hello::greet();

Syntax explanation

package Hello;  # Declare a package; file must be saved as

sub greet {     # Contents of the package: functions, and variables
  return "Hello world!";
1;              # Return a true value at end

Table of Contents.