{"id":224,"date":"2010-09-07T08:12:06","date_gmt":"2010-09-07T15:12:06","guid":{"rendered":"http:\/\/35.225.155.113\/blog\/index.php\/2010\/09\/07\/submitting_a_perl_module_to_cpan\/"},"modified":"2019-10-13T12:49:50","modified_gmt":"2019-10-13T19:49:50","slug":"submitting-a-perl-module-to-cpan","status":"publish","type":"post","link":"https:\/\/www.weinstein.org\/blog\/index.php\/2010\/09\/submitting-a-perl-module-to-cpan.html","title":{"rendered":"Submitting a Perl module to CPAN"},"content":{"rendered":"<p>Last May, I finally made available for download the first version of <a href=\"http:\/\/pdw.weinstein.org\/2010\/05\/perl-module-webserviceviddler-on-cpan.html\">Webservice::Viddler on CPAN<\/a> (<a class=\"zem_slink rdfa\" title=\"CPAN\" href=\"http:\/\/en.wikipedia.org\/wiki\/CPAN\" rel=\"ctag:means wikipedia\">Comprehensive Perl Archive Network<\/a>) after having <a href=\"http:\/\/pdw.weinstein.org\/2010\/03\/viddler-api-via-perl.html\">written about it in March<\/a>. One of the reasons for the delay in making the packaged source code available for download had to do with one simple fact, the Viddler module was my first ever submitted for public consumption.<\/p>\n<p>Now, don&#8217;t misunderstand me, Webservice::Viddler is not the first <a class=\"zem_slink rdfa\" title=\"Perl\" href=\"http:\/\/www.perl.org\/\" rel=\"ctag:means homepage\">Perl<\/a> module I have ever written. I&#8217;ve been writing code in Perl for about as long as CPAN has existed. However, as is the case with my current work in <a class=\"zem_slink rdfa\" title=\"PHP\" href=\"http:\/\/www.php.net\/\" rel=\"ctag:means homepage\">PHP<\/a> for <a href=\"http:\/\/www.orbitmedia.com\/\">Orbit Media Studios<\/a>, most of the Perl code I wrote over the years was on behalf of a employer of some sort. As such the ownership of the code, and the right to distribute, rested with them, not me.<\/p>\n<p>So then, why the delay? Well there are a couple of reasons. First of all, the code I posted in March was a proof of concept based on some work I did for Orbit at the time. While the basic framework of the module worked the &#8220;proto-module&#8221; didn&#8217;t implement all of the functionally provided by the <a href=\"http:\/\/developers.viddler.com\/documentation\/api\/\">Viddler Web API<\/a>.<\/p>\n<p>Secondly, I needed to organize the source code for proper distribution on <a href=\"http:\/\/www.cpan.org\">CPAN<\/a> as well as get the packaged distribution uploaded and made available.<\/p>\n<p><b>The Packaging<\/b><br \/>\nBefore I did anything, I wanted to make sure that my module had all of the necessary files. In doing a little googling, I came across a blog post entitled <a href=\"http:\/\/blogs.encodo.ch\/news\/view_article.php?id=63&amp;panel=article\">Submitting a CPAN module<\/a> which outlines the basic steps:<\/p>\n<ol>\n<li>\n<p style=\"margin-bottom: 0in;\">Apply for an account on PAUSE (Perl Authors Upload Server)<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0in;\">Organize your code<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0in;\">Profit<\/p>\n<\/li>\n<\/ol>\n<p>Not too complex, granted, but organized how?<\/p>\n<p>As the author notes there doesn&#8217;t seem to be any &#8220;what the package must have&#8221; rules. However, as anyone who has worked with third-party Perl modules knows, there is an accepted process and organization of code that all modules tend to adhere to.<\/p>\n<p>After a little more googling I came across <i>module-starter<\/i>, a handy command-line interface to a Perl module, <a href=\"http:\/\/search.cpan.org\/%7Epetdance\/Module-Starter-1.54\/bin\/module-starter\">Module::Starter<\/a>, which does all the work of creating a base module for distribution. After adding in my code and documentation I quickly had something close to ready.<\/p>\n<p>Close, but not complete. Besides making the package useful to install, I wanted to make the code useful to modify. For that I turned to <i>perltidy<\/i> <a href=\"http:\/\/perltidy.sourceforge.net\/\">a Perl script<\/a> which indents and reformats Perl code to makes it easier to read and follow.<\/p>\n<p>Great! Now here is where this can get interesting (and where a lot of suggestions, if not outright rules, do exist). If you follow the steps in the order above, good, because that means while waiting for a PAUSE account to come online<a class=\"sdfootnoteanc\" href=\"#sdfootnote1sym\" name=\"sdfootnote1anc\"><sup>1<\/sup><\/a>, proper considerations can be made for the naming of the module.<\/p>\n<p><b>The Namespace<\/b><br \/>\nThe PAUSE documentation <a href=\"http:\/\/pause.perl.org\/pause\/query?ACTION=pause_namingmodules\">On The Naming of Modules<\/a> notes that &#8220;a module name must accomplish quite a bit in a few characters&#8221;, such as provide context as to what the module does or problem it addresses. Also of importance is the fact that &#8220;once chosen, you rarely have the opportunity to change it after people start using it.&#8221;<\/p>\n<p>So a little careful consideration is in order.<\/p>\n<p>Also, it is important to note that namespaces, <a href=\"http:\/\/en.wikipedia.org\/wiki\/Namespace\">by definition<\/a>, are unique. Besides providing a singular meaning, the name cannot be shared with some other module, public or otherwise. As such it is recommend that PAUSE developers register the namespace of the module written. Again, this isn&#8217;t a hard and fast rule per se, but a recommendation to avoid duplication and improve searchability.<\/p>\n<p>That about covers the basics. Now, if you will excuse me, I need to take some time to <a href=\"http:\/\/www.cpantesters.org\/distro\/W\/WebService-Viddler.html\">address these test results<\/a>.<\/p>\n<hr>\n<div id=\"sdfootnote1\">\n<p class=\"sdfootnote\"><a class=\"sdfootnotesym\" href=\"#sdfootnote1anc\" name=\"sdfootnote1sym\">1<\/a> The PAUSE documentation suggests allowing up to &#8220;three weeks for proceeding&#8221; but that requests a usually completed &#8220;within a week.&#8221;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>There doesn&#8217;t seem to be any &#8220;must have&#8221; rules, but as anyone who has worked with Perl modules knows, there is an accepted organization that most tend to adhere to.<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[92],"tags":[289,7,44,297,43,281,298],"_links":{"self":[{"href":"https:\/\/www.weinstein.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/224"}],"collection":[{"href":"https:\/\/www.weinstein.org\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weinstein.org\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weinstein.org\/blog\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weinstein.org\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=224"}],"version-history":[{"count":8,"href":"https:\/\/www.weinstein.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/224\/revisions"}],"predecessor-version":[{"id":703,"href":"https:\/\/www.weinstein.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/224\/revisions\/703"}],"wp:attachment":[{"href":"https:\/\/www.weinstein.org\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weinstein.org\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weinstein.org\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}