A custom module can be created for code that needs to be used in numerous Perl scripts. As a sort of silly but easy example, let's say you want to print a welcome message at the beginning of each of your Perl scripts. First, create a module.
~]# touch /usr/share/perl/modules/foo.pm
In the module, add your welcome message, such as "Welcome to my Perl script."
#!/usr/bin/perl print "Welcome to my Perl script\n";
Here is how you would use the module.
#!/usr/bin/perl use strict; use warnings; use lib "/usr/share/perl/modules"; use foo;
Now, when running your Perl modules, "Welcome to my Perl script" will be printed to the console.
If something is not working as expected, add the following to your Perl script to validate that the directory that contains your module is included.
print join ( "\n", @INC );