Classnotes | UNIX01 | RecentChanges | Preferences No diff available--this is the first major revision.
(no other diffs)One of Perl's programming strengths is in the fact that you can call on and snap in new functionality through the use of objects called "Modules".
A Perl Module is slightly like a library in another application, except more atomic than standard libraries are. A piece of Perl code and be both a stand alone script and a module for snapping into another external application.
Perl Modules can usually be installed rather easily using the Comprehensive Perl Archive Network, CPAN (http://cpan.org/), and there are Modules for just about every need you could ever have.
A modules is added to a Perl script with the "use" command. For example, if in my script I wanted to use the POSIX module, I would add the following at the beginning
use POSIX;
You can also specify specific functions or procedures from a module by including those functions in single-quotes. For example, if all I wanted from POSIX was the "strftime" function, my syntax would be
use POSIX 'strftime';
Sometimes, a specific module will have a sub-module (or several layers of sub-modules). These can be specified using the "::" deliminator. For example, if I wanted the File module's Copy submodule, I would have
use File::Copy;
Occassionally, you may have need for a Perl script to run using a certain version of Perl. Sometimes multiple versions of Perl exist on a given system for maximum compatibility. Passing a version number to "use" will allow you to specify the version needed.