Perl module: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 1:
A '''Perl module''' is a discrete component of software for the [[Perl]] programming language. ATechnically, moduleit is distinguished by a uniqueparticular namespace, e.g. "CGI" or "Net::FTP" or "XML::Parser" and a filename similarly named (ie. Net::FTP lives in Net/FTP.pm). A collectionset of oneconventions orfor moreusing modules,Perl's with[[package]] accompanyingmechanism documentation and build scripts, compose a distribution. The Perl communitythat has abecome sizableuniversally library of distributions available for search and download via [[CPAN]]adopted.
 
A module defines its source code to be in a '''package''', the Perl mechanism for defining [[namespace]]s, e.g. ''CGI'' or ''Net::FTP'' or ''XML::Parser''; the file structure mirrors the namespace structure (e.g. the [[source code]] for ''Net::FTP'' is in ''Net/FTP.pm''). This mechanism is similar to that of [[Java package]]s. Furthermore, a module is the Perl equivalent of the [[class (computer science)|class]] when[[object-oriented programming]] is employed.
 
A collection of one or more modules, with accompanying documentation, build scripts, and usually a test suite, compose a '''distribution'''. The Perl community has a sizable library of distributions available for search and download via [[CPAN]].
 
Perl is a language allowing many different styles of programming. You're as likely to find a module written in a [[procedural]] style (for example, [http://search.cpan.org/dist/Test-Simple Test-Simple]) as [[object-oriented]] (e.g. [http://search.cpan.org/dist/XML-Parser XML-Parser]), both are considered equally valid according to what the module needs to do. Modules might also be used to [[mixin]] methods ([http://search.cpan.org/dist/DBIx-Class DBIx-Class]) or be a [[compiler directive|pragma]] ([http://perldoc.perl.org/strict.html strict.pm]) which has an effect immediately upon being loaded. Modules can even be used to alter the syntax of the language. The effect of Perl modules are usually limited to the current [[scope (programming)|scope]] in which it was loaded.