Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Questions about creating CPAN modules

by gsiems (Deacon)
on Oct 13, 2009 at 02:42 UTC ( #800835=perlquestion: print w/replies, xml ) Need Help??
gsiems has asked for the wisdom of the Perl Monks concerning the following question:


This weekend I uploaded my very first module (Padre::Plugin::ShellCommand) to CPAN. Though it is but a meager offering, it pleases me greatly to make it. However, having gotten over my initial feelings of great satisfaction and accomplishment, I have a few questions.

Primoris - Checking the dependencies link, it appears that the necessary information for establishing dependencies is not available. What files/information need to be added so that this works correctly?

Secundus - This module depends on having an adequate shell environment (sh, which, and cat). Since these dependencies aren't CPAN modules, I find myself meditating on how one can specify them so that they are properly checked for when installing the module. Is this doable? Recommended?

Tertius - In using How to make a CPAN Module Distribution as my guide in preparing this module I found no mention of META.yml which manuscript appears in many other modules. This does not appear to be auto generated. Must it be manually created? Must it be created at all?

Gratiae ultum,


Replies are listed 'Best First'.
Re: Questions about creating CPAN modules
by Corion (Pope) on Oct 13, 2009 at 06:53 UTC

    For the dependencies, I think your PREREQ_PM section is OK:

    PREREQ_PM => { 'Test::More' => 0, 'File::Temp' => 0, 'Padre' => 0.43, },

    Maybe the CPAN dependencies don't update as quickly.

    As for requiring a "shell" environment, Module::Install has a function requires_external_bin, which allows you to specify external dependencies.

    Personally, instead of relying on cat, which and sh, I would use Perl to implement these (well, except sh) to remove these dependencies instead of programming detections :).

    About META.yml, I think make meta or something like that (re)creates that file.


      I'll have a study on Module::Install and it's requires_external_bin.

      which: Seek and ye shall find... I should have sought first. It appears that CPAN already has a File::Which. One down...

      cat: While there is a File::Cat, it appears to merely concatenate files, whereas I was using cat for it's ability to expand environment variables and assorted backticked commands. For example:

      cat <<EOT It is `date` and $USER needs more coffee. EOT

      I'm not even sure where to begin to re-impliment that in perl.


        What you rely on is no magic on the part of cat but more on the part of /bin/sh, and no, there is no easy way to replicate that functionality as-is without writing a shell interpreter.

Re: Questions about creating CPAN modules
by DrHyde (Prior) on Oct 13, 2009 at 09:49 UTC

    Primis: relies on META.yml for dependencies, because it can't reliably and safely parse Makefile.PL. You don't have one, therefore it "couldn't get dependencies". I see that you use ExtUtils::MakeMaker. Did you "make dist" to create the tarball that you uploaded to the CPAN? If not, try that, and it should automagically create a META.yml file for you and include it in the tarball. If it doesn't, then you may need to upgrade ExtUtils::MakeMaker.

    Secundus: cat and which at least are trivial to implement in perl. sh isn't, of course, but you may be able to get the user's preferred shell from CPAN::Config. You can probably assume an "adequate shell environment" if you're running on something Unixy, Cygwin, or BeOS - you could use Devel::CheckOS for that. I suppose I should consider adding an OS "family" to that distribution to match "has a useful shell" but I can't think what to call it. Suggestions by email or in RT please.

    Tertius: that node is seven years old and quite out of date. Ignore it.

      Thank you,

      Primis: make dist does the trick! Excellent.

      Secundus: I suppose I should consider adding an OS "family" to that distribution to match "has a useful shell" but I can't think what to call it. -- I pondered that myself and had actually considered naming it Padre::Plugin::ShellCommand::Unix but that didn't *feel* right. I thought that with some tweaks to the module, and with a little wrangling on the OS side, this module could be used under a non-unix/unix like OS.

      Tertius: It appears that the module building landscape has changed somewhat in the past seven years.


        I would like to reccomend Test::XT and make disttest

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://800835]
Approved by muba
[Corion]: Gratulations! :-D

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-02-22 09:23 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (289 votes). Check out past polls.