chrestomanci has asked for the wisdom of the Perl Monks concerning the following question:

I have been a Perl programmer for over 10 years, but until joined this monastery about 6 months ago, I did not engage with the community in any way. Now that I am more engaged, I am thinking that I should be uploading some of the stuff that I have written to CPAN, as it may be useful to other people.

At this stage, I am thinking of a few scripts (not modules) that I have put a fair amount of effort into over the past couple of years, use frequently, but not really shared with anyone beyond a few colleges and friends.

I went over to PAUSE, and read about requesting an account. The guidelines look rather uninviting, and make it sound that only the best quality modules will make the cut, and lesser code need not apply

Is that relay the case? Would a bunch of random scripts be considered a useful addition to CPAN? or should I keep them to myself, and perhaps only publish them on my home page. (Which gets no traffic).

Replies are listed 'Best First'.
Re: On uploading scripts to CPAN
by toolic (Bishop) on Mar 19, 2011 at 17:48 UTC
    I encourage you to upload code that is of high quality and is unique, especially if you plan to maintain it.

    Before uploading anything to CPAN, you should perform a thorough search on CPAN to make sure your code is not redundant. If there is something already on CPAN that is similar to what your code does, try to assess whether your code is better in some way, such as:

    • More features
    • Faster
    • Consumes less memory
    • Much easier to use

    If you are convinced your code is unique enough, then make sure its quality is as good as it can be. Generally, people want code that is easy to use and is bug free. That means that it must have documentation (written in POD) and it must have tests. You might consider converting your scripts into modules by moving the subs into the module, then providing a simple wrapper script for easy usage. Using subs makes code easier to test.

    I would not advocate uploading "a bunch of random scripts", especially if they are unrelated to each other.

Re: On uploading scripts to CPAN
by Corion (Patriarch) on Mar 19, 2011 at 17:43 UTC

    There is no quality control on CPAN, so your impression that "only the best quality modules will make the cut" is likely wrong :).

    People have often uploaded scripts to CPAN, either as "modulinos" within the App namespace or as stand-alone scripts. I've "uploaded" most of my "generally useful" scripts here in Cool Uses For Perl.

      Although there is no formal quality control, people do make use of the cpan ratings to voice their opinion.

      My advice is to run your stuff by other people before uploading, if you're not sure. Choosing the wrong module name will get you grief from others. Some people don't read the pause docs and use non-descriptive top-level namespaces (e.g. Water !?) or create a namespace for their cpanid (e.g. DPCHRIST).

      And instead of just reading docs to figure out the conventions, choose a few respected, and recently updated, modules to crib from.

        Although there is no formal quality control, people do make use of the cpan ratings to voice their opinion.

        From what I've seen most modules are unrated. Of those that are rated many have either been rated by the author or by members of the author's fan club, or by someone with a bee in their bonnet about some particular aspect of the module. I advise taking CPAN module ratings with a very large grain of salt!

        True laziness is hard work
        And if you want to share but don't care about quality or maintenance, you could always upload to github or bitbucket.

      Thanks for your input.

      Rest assured that I was never planning to upload junk, but scripts which I consider to be good quality, and which others around me agree, however I am thinking single file perl scripts rather than perl modules or applications where the logic live in .pm files rather than the main script.

      From Corion's advice, it looks like the best approach would be to refactor the script to move as much functionality as is reasonable into separate perl modules or classes. These perl modules can then be shared on CPAN. The (hopefully) small script that is left after most of it's logic goes into modules can then be added as an optional script in the /bin directory of one of the module bundles.

      Thinking about how I would do that re-factoring, I considered the functional components and searched CPAN for equivalent code by other authors. I found that in one area (An interface to IMDB someone else has already an alternative module), so I won't be duplicating that, instead I will modify my scripts, to use the module, and will be sending the module author patches and bug reports.

      In other areas, I did not find anything on CPAN that covers what I have done, so I guess I will be polishing my code and adding tests so that I can upload it. I don't think I will be uploading any actual scripts for a while.

      Thank you all for your comments.