Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Perl Monk, Perl Meditation
 
PerlMonks  

What's the best way to handle the installation and or distribution of a Perl script?

by taint (Hermit)
on Nov 24, 2013 at 21:17 UTC ( #1064145=perlquestion: print w/ replies, xml ) Need Help??
taint has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, Monks.

I've been laboring over this for awhile, and can't seem to come up with the ultimate/ideal answer.

More specifically; If I intend to create a distribution comprised of only a simple Perl script (somescript.pl). Does it make any sense to even attempt a typical install?

perl Makefile.PL make make test # if all tests pass make install
or does it simply make more sense to make the install sub simply emit a message:
This really isn't a Perl Module proper, but more a utility\n script, written in Perl. You would probably be best served by\n copying this script to your local (s)bindir, or to your systems\n equivalent (if you posses the rights to do so).

If in the "traditional" sense of a distribution; how might I best determine what system (OS) I'm on, in order to copy the script to a proper "bindir". I'm guessing to the Perl dir is probably the best choice. But thought I'd ask. To get thoughts on the matter, I hadn't already considered.

Tnanks for all your consideration.

--Chris

#!/usr/bin/perl -Tw
use Perl::Always or die;
my $perl_version = (5.12.5);
print $perl_version;

Comment on What's the best way to handle the installation and or distribution of a Perl script?
Select or Download Code
Re: What's the best way to handle the installation and or distribution of a Perl script?
by Utilitarian (Vicar) on Nov 24, 2013 at 22:24 UTC
    The $^O variable ($OSNAME if you "use English;") contains an indication of the name of the operating system (not its release number) that the perl binary was built for.

    print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
      I would caution that there is always the possibility that a future release of your utility may require its own modules and so a standard release may be advisible but for simple releases dropping a script which requires a minimum Perl version in a directory on the standard path should suffice.
      print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
Re: What's the best way to handle the installation and or distribution of a Perl script?
by Anonymous Monk on Nov 24, 2013 at 23:01 UTC

    modulinos / modulinos , distributions / distributions

    Does it make any sense to even attempt a typical install?

    Yes, absolutely, its what its for

    or does it simply make more sense to make the install sub simply emit a message:

    "install sub"? pointless busywork ... and annoying too (stupid computer program here, you've asked me dance, but I want YOU to dance monkey)

    If in the "traditional" sense of a distribution; how might I best determine what system (OS) I'm on, in order to copy the script to a proper "bindir".

    In the traditional sense of a distribution, its none of your business; let ExtUtils::MakeMaker, or Module::Install handle it for you, cause thats its job; If you still want to know, you know where to look :)

    I'm guessing to the Perl dir is probably the best choice. But thought I'd ask. To get thoughts on the matter, I hadn't already considered.

    You've got enthusiasm, FANTASTIC, now leverage that enthusiasm to employ less guessing, more RTFM, more super search, more try it to see ... before you burn out and the enthusiasm wanes

    modulinos / modulinos , distributions / distributions

      Points well taken.

      Fact is, it's quiet here today, and while I'm aware of documentation. I see very little (nearly none) specific information regarding such an endevour. I actually spent a great deal of time on this (looking). As I thought it might be a great "how-to" Module/FAQ for aspiring Authors. There's volumes of information on the creation/maintaining of "typical" Module creation, but precious little on simple script authoring/maintenance. So hence initiating this thread here on PerlMonks for input/feedback.

      --Chris

      #!/usr/bin/perl -Tw
      use Perl::Always or die;
      my $perl_version = (5.12.5);
      print $perl_version;
Re: What's the best way to handle the installation and or distribution of a Perl script?
by Laurent_R (Priest) on Nov 24, 2013 at 23:09 UTC

    Thank you for asking the question, Chris, I'll watch the answers carefully.

    I have a similar problem. I have written about a dozen modules in the recent past, but all of them were too specific to our company's needs to justify the idea of publishing them on the CPAN or elsewhere. But I wrote relatively recently a module for comparing large data files which I think may be useful to other users. This module can remove duplicate records, find and remove "orphans" (records in one file and not the other) and then compare the data. I have used that module in two different contexts, and it does what is needed and I think it works well. And I wrote it at home on my free time, so that I can really make it public domain or free software or whatever other adequate free access license.

    My main problem, though, is that I do not know how to do a CPAN distri. Especially, I do not know how to provide test cases that will work with Unix files, Windows files, VMS files and so on.

      Merci pour tes mots gentils, Laurent_R.
      I hope I stated that properly. :)

      My current thoughts on this is (given the script contains POD), is to copy all of the documentation from it into a Perl Module. Then simply following the normal course of creating, and distributing a Perl Module. So the final results being: somescript.pl
      SomeScript.pm
      I already have a Makefile.PL to do that. But thought I'd wait to post it. To see what other thoughts, ideas, implementations others had, first.

      Merci encore.

      --Chris

      #!/usr/bin/perl -Tw
      use Perl::Always or die;
      my $perl_version = (5.12.5);
      print $perl_version;

        While there indeed are Modules that can perform the task of automating the task of creating a Dist for CPAN. Those that are specific to single utility type Perl scripts are somewhat few, by comparison. Those that do exist, are largely unfinished. In anticipation of releasing a full fledged, and complete Module for the automation of creating, and distributing of either a standard Perl Module, or Perl script(s). I initiated this endevour ~month ago. Searching for documentation, while available. Wasn't where I anticipated it's being, and was a bit chopped up. I then embarked on a search for Modules that either were "how-to's" (POD's, and such), or were complete Automation dists, for the sake of completely automating the task of creating, and pushing your dist to CPAN. As noted earlier, they existed. Those that worked best, were intended for a typical Perl Module. Those for scripts, while could work. Were best suited for those already comfortable using CPAN, and were already relatively seasoned authors.

        So I thought my idea a worthy cause. It was my intention, after completion of the Module, to post an RFC in Meditations. Given that. I'll end much further discussion of it here. In order to keep things in context.

        Given that my original intent was to elicit comments from others on how they would choose to create a dist on CPAN that was meerly a utility type script. I'll post the one I use (Makefile.PL). Hopefully, my submission might elicit the dialog I had hoped for. :)

        use 5.008_005; use strict; use warnings FATAL => 'all'; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'examplescript', AUTHOR => q{Judy Garland <judygarland@wizard.oz>}, VERSION_FROM => 'lib/examplescript.pm', EXE_FILES => ['examplescript'], ABSTRACT_FROM => 'lib/examplescript.pm', LICENSE => 'artistic', PL_FILES => { # examplescript.pl }, MIN_PERL_VERSION => 5.008_005, CONFIGURE_REQUIRES => { 'ExtUtils::MakeMaker' => 0, }, BUILD_REQUIRES => { 'Test::More' => 0, }, PREREQ_PM => { 'File::Spec' => 0, 'Term::ReadLine' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'examplescript-*' }, );
        While I didn't need to also create a examplescript.pm, I chose to, only to provide an additional "help file" (it only contains what would be dumped to the man files -- man.1, and man.3). It also contains a little bonus --
        samplescript.pm exports nothing. Perhaps you're looking for the script examplescript(.pl) try perldoc examplescript for more information.
        Anyway, it does the job quite adequately, and will/would pass the "smoke" test(s) on cpantesters.

        That's all for now. :)

        --Chris

        #!/usr/bin/perl -Tw
        use Perl::Always or die;
        my $perl_version = (5.12.5);
        print $perl_version;
Re: What's the best way to handle the installation and or distribution of a Perl script? ( Where can I find Perl scripts? How do I contribute scripts to CPAN? naming modules, names to avoid, Guidelines for Reusing Application Code, What sho
by Anonymous Monk on Nov 25, 2013 at 02:42 UTC
Re: What's the best way to handle the installation and or distribution of a Perl script?
by mrider (Sexton) on Nov 25, 2013 at 17:28 UTC

    I was in a similar situation to yours some little while ago. I had a rather poorly written module which I would move into the correct directory by hand for use on my own computer. One day I decided that I should really learn how to do this properly. I went the full route. I added tests. I added taint mode testing. I put in all the various bits and bobs that make this very CPAN like.

    I've since had to remove and re-install Perl on my Win32 machine several times, and let me tell you, the convenience of being able to just change into the source directory and install cannot be overstated.

    It was also worthwhile since I learned so much. I don't work in a Perl shop, nor have I ever worked with anyone else that uses Perl. Which makes my Perl skills dubious at best. Frankly, going through the work to create a quality (at least by my standards) build of my module was well worth it!



    I would suggest reading How to make a CPAN Module Distribution in the tutorials. Also, while "Super Search" is awesome, you would be well served just following the tutorial link and reading the stuff there.

    The additional skills you acquire doing this will serve you well in other code writing, and it's well worthwhile IMHO.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1064145]
Approved by Old_Gray_Bear
Front-paged by davies
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-04-17 22:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (458 votes), past polls