Ағылшыншамен салыстырыңыз: абзацты басыңыз — түпнұсқа терезеде ашылады. Абзац астындағы EN түймесі оны мәтін ішінде көрсетеді.
Кіріспе
Perl модулі – Perl бағдарламалау тілі үшін бағдарламалық қамтамасының жеке компоненті. Техникалық тұрғыдан алғанда, бұл Perl-дің пакеттік механизмін пайдалану үшін әмбебап қабылданған конвенциялар жиынтығы. Модуль өзінің бастапқы кодын пакет ішінде анықтайды (Java пакетіне ұқсас), бұл атау кеңістіктерін анықтау үшін Perl механизмі, мысалы, CGI немесе Net::FTP немесе XML::Parser; файл құрылымы атау кеңістігі құрылымын шағылыстырады (мысалы, Net::FTP-нің бастапқы коды Net/FTP.pm ішінде орналасқан). Сонымен қатар, модуль объектіге бағытталған бағдарламалау қолданылған кезде кластың Perl эквиваленті болып табылады. Модульдер жинағы, олармен бірге жүретін құжаттама, құрастыру скрипттері және әдетте тест жиынтығы дистрибутивті құрайды. Perl қауымдастығы CPAN арқылы іздеуге және жүктеуге қолжетімді үлкен дистрибутивтер кітапханасына ие. Perl – көптеген түрлі бағдарламалау стильдерін қолдайтын тіл. Әзірлеуші процедуралық стильде жазылған модульді (мысалы, Test::Simple) немесе объектіге бағытталған модульді (мысалы, XML::Parser) табуы мүмкін, екеуі де модульдің міндеттеріне сәйкес бірдей жарамды деп есептеледі. Модульдер әдістерді қосу (DBIx::Class) үшін немесе прагма (strict.pm) ретінде де қолданылуы мүмкін, ол жүктелгеннен кейін бірден әсер етеді. Модульдер тілдің синтаксисін өзгерту үшін де пайдаланылуы мүмкін. Perl модульдерінің әсері әдетте олар жүктелген ағымдағы ауқыммен шектеледі. Perl модульдерінде Perl-дің Plain Old Documentation форматындағы құжаттамалардың кіріктірілуі жиі кездеседі. POD авторға көп құрылымды талап етпейді. Ол мақалалар, веб-беттер және тіпті Perl бағдарламалау сияқты кітаптарды жазу үшін жеткілікті икемді. Java сыныптарын құжаттауға арналған javadoc-пен салыстырыңыз. Көбінесе модуль құжаттамасы Unix-тің нұсқаулық бетінің құрылымын ұстанады. Perl тілі бірнеше рет жаңартылып, ("perl" деп аталады) және әр жаңа нұсқаға қосылады (және сирек жағдайларда алынып тасталады). Сондықтан модуль авторлары үшін қандай мүмкіндіктерді пайдаланатынын және Perl-дің ең төменгі қажетті нұсқасын білу маңызды. Бұл беттегі код perl 5.6.0 нұсқасын қажет етеді, ол қазір ескі деп саналады.
A Perl module is a discrete component of software for the Perl programming language. Technically, it is a particular set of conventions for using Perl's package mechanism that has become universally adopted. A module defines its source code to be in a package (much like a Java package), the Perl mechanism for defining namespaces, 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). Furthermore, a module is the Perl equivalent of the class when object oriented programming is employed. A collection of modules, with accompanying documentation, build scripts, and usually a test suite, composes 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. A developer is as likely to find a module written in a procedural style (for example, Test::Simple) as object oriented (e. g. XML::Parser), both are considered equally valid according to what the module needs to do. Modules might also be used to mixin methods (DBIx::Class) or be a pragma (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 in which it was loaded. It is common for Perl modules to have embedded documentation in Perl's Plain Old Documentation format. POD imposes little structure on the author. It is flexible enough to be used to write articles, web pages and even entire books such as Programming Perl. Contrast with javadoc which is specialized to documenting Java classes. By convention, module documentation typically follows the structure of a Unix man page. The language of Perl is defined by the single implementation (referred to as "perl") and is added to (and in rare occasions taken away from) each new release. For this reason it is important for a module author to be aware what features they're making use of and what the minimum required version of perl is. The code on this page requires perl 5.6.0 which is considered rather old by now.
Процедуралық мысал
Міне, "Сәлем, Әлем" процедуралық модуль ретінде іске асырылды, сәлемдеменің адресатын өзгертуге мүмкіндік береді, жай ғана қызықты болу үшін. Модульдің қолданылуын көрсету үшін қысқа сценарий де қосылды.
Here is "Hello, World" implemented as a procedural module with a customizable target for the greeting, just to make things interesting. Also included is a short script to illustrate the module's use.