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

As a young Perl developer (not in age, just in my time in Perl), I hang out and rarely contribute much, as I'm in the learning stage.

One thing I've noticed, though, is that the answer to many questions posted is to provide a reference to a CPAN module that simplifies the task.

While I think that's great, the reality of my work environment is that I can't count on many modules (outside of CGI and DBI) to exist on all the boxes my scripts may find themselves on, as they are owned by different departments and maintained by different owners.

Which makes me wonder... is there a generally-accepted set of Perl modules that I could reasonably expect to find on any box I find myself on?

Or, should I write without modules as much as possible to help ensure compatibility?

Thanks in advance,

Trek

  • Comment on Minimum CPAN modules you should count on?

Replies are listed 'Best First'.
Re: Minimum CPAN modules you should count on?
by Fletch (Bishop) on Jun 28, 2004 at 20:46 UTC

    perldoc perlmodlib lists what's core (i.e. what ships with perl itself). Past that you need to bug your sysadmin about integration with your OS' package managment software (see FreeBSD's bsdpan that makes CPAN modules appear as ports, for example) and read perldoc CPAN for information on the autobundle command.

    Update: Also look at PAR for a mechanism for packaging up all your dependencies into a single file which will run regardless of what's installed on the other end.

      Yeah, I went the PAR route for deploying Perl apps on multiple Win32 desktops. The code I inherited had some rather yucky 'auto-install-if-the-module-is-missing' code tucked away in a BEGIN block.

      I don't remember exactly how the code went but it was something like this

      BEGIN { eval { require FOO::Bar }; if ($@) { system("ppm install FOO::Bar"); } }

      PAR is by far the better way to go :-)

      -- vek --
Re: Minimum CPAN modules you should count on?
by gri6507 (Deacon) on Jun 28, 2004 at 21:38 UTC
    If your scripts need to use non-core modules, you could always deliver those along with your script (to any directory that is in %INC). PAR is a way to automate that.
Re: Minimum CPAN modules you should count on?
by sgifford (Prior) on Jun 28, 2004 at 21:49 UTC
    Why can you only use modules that you find on that box? It's fairly straightforward to go out to CPAN and get anything that you need, and as gri6507 suggests, you can package those modules along with your program if you're installing them on machines that aren't connected to the Internet. If you're concerned about making a mess of their Perl installation somehow, you can create your own library directory, install the modules in there (by setting PREFIX when running perl Makefile.PL), then just reference them from your scripts (with use lib or PERL5LIB).
Re: Minimum CPAN modules you should count on?
by pbeckingham (Parson) on Jun 29, 2004 at 00:13 UTC

    I agree with what you're saying here, in that it often becomes so easy for us to respond to a newbie with "just use Some::Thing". Often I feel that folks want a pure Perl answer, because some of the questions are about exploration of the language, not necessarily about implementation on a deadline, or within budget.

    I said something like this in Standard Perl Modules ~ Overkill, namely that if an answer can be specified using Perl core modules, that is just as good, then perhaps it should be. I don't think it was a particularly widely held opinion.