{"id":1695,"date":"2016-10-10T10:58:23","date_gmt":"2016-10-10T08:58:23","guid":{"rendered":"http:\/\/blog.rabahi.net\/?page_id=1695"},"modified":"2016-10-10T11:01:32","modified_gmt":"2016-10-10T09:01:32","slug":"perl-create-perl-module-pm","status":"publish","type":"page","link":"https:\/\/blog.rabahi.net\/?page_id=1695","title":{"rendered":"Perl &#8211; Create Perl Module (.pm)"},"content":{"rendered":"<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#Perl_Module\"><span class=\"toc_number toc_depth_1\">1<\/span> Perl Module<\/a><\/li><li><a href=\"#Use_it\"><span class=\"toc_number toc_depth_1\">2<\/span> Use it<\/a><ul><li><a href=\"#Import_my_Perl_Module\"><span class=\"toc_number toc_depth_2\">2.1<\/span> Import my Perl Module<\/a><\/li><li><a href=\"#Call_methods\"><span class=\"toc_number toc_depth_2\">2.2<\/span> Call methods<\/a><\/li><\/ul><\/li><\/ul><\/div>\n<h1><span id=\"Perl_Module\">Perl Module<\/span><\/h1>\n<p>Create the following file : MyPerlModule.pm<\/p>\n<pre lang=\"perl\">\r\nuse strict;\r\nuse warnings;\r\n\r\npackage MyPerlModule;\r\n\r\nsub method1\r\n{\r\n  my $param1 = shift;\r\n  my $param2 = shift;\r\n  (...)\r\n  my $paramN = shift;\r\n\r\n  # Here is my method1 impl\u00e9mentation.\r\n  (...)\r\n}\r\n\r\nsub method2\r\n{\r\n  my $param1 = shift;\r\n  my $param2 = shift;\r\n  (...)\r\n  my $paramN = shift;\r\n\r\n  # Here is my method1 impl\u00e9mentation.\r\n  (...)\r\n}\r\n\r\n# always finish perl module with true :\r\n1;\r\n<\/pre>\n<h1><span id=\"Use_it\">Use it<\/span><\/h1>\n<h2><span id=\"Import_my_Perl_Module\">Import my Perl Module<\/span><\/h2>\n<pre lang=\"perl\">\r\nrequire \"my\/relativ\/path\/to\/MyPerlModule.pm\"\r\n<\/pre>\n<h2><span id=\"Call_methods\">Call methods<\/span><\/h2>\n<pre lang=\"perl\">\r\n# static call :\r\nMyPerlModule:method1(param1,param2,...,paramN);\r\n\r\nMyPerlModule:method2(param1,param2,...,paramN);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Contents1 Perl Module2 Use it2.1 Import my Perl Module2.2 Call methods Perl Module Create the following file : MyPerlModule.pm use strict; use warnings; package MyPerlModule; sub method1 { my $param1 = shift; my $param2 = shift; (&#8230;) my $paramN = shift; # Here is my method1 impl\u00e9mentation. (&#8230;) } sub method2 { my $param1 = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1693,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1695","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1695"}],"version-history":[{"count":3,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1695\/revisions"}],"predecessor-version":[{"id":1698,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1695\/revisions\/1698"}],"up":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1693"}],"wp:attachment":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}