Scarface
Scarface

Reputation: 3923

How to install dependencies of a Perl script?

I am trying to execute a daemon that runs on Perl, and the file is called ffencoderd.pl. Every time I run it, it states that a file is missing, for example Can't Locate IO/Scalar.pm.

So I go to CPAN.org and find the file and install it. The only problem is that I have just installed like 6 files and I am worried that there may be 20 more. Rather than keep running ffencoderd.pl and find that I need to install another file, I was wondering if there was a way to update perl. Are these files standard in a properly installed Perl? EX: Config-General-2.50, Pod-Xhtml-1.61, libxml-enno-1.02, etc.

Upvotes: 5

Views: 11237

Answers (3)

zellio
zellio

Reputation: 32534

Updating perl should be done through your package manager. Module installation for perl from CPAN should be handled by the CPAN utility which is generally invoked in the command line by something like perl -MCPAN -e shell. CPAN will handle package requirements and proper installation procedure.

Upvotes: 2

cjm
cjm

Reputation: 62109

Updating Perl won't help you, because the missing modules are not part of the core Perl distribution; they have to be installed separately. Tools like cpanm will help you install modules (given a list of required modules), but they can't look at a script and figure out what modules it needs. The script's author should have done that, but apparently didn't. Update: If you're talking about this ffencoderd.pl, the author did list the required modules. You need to install IPC::ShareLite, Config::General, SOAP::Lite, XML::DOM, XML::Simple, Pod::WSDL, Pod::Xhtml, and HTML::Template.

The easiest way to install these is to install cpanm and then type:

cpanm IPC::ShareLite Config::General SOAP::Lite XML::DOM XML::Simple Pod::WSDL Pod::Xhtml HTML::Template

If you didn't have a list of modules to install, this question is about figuring out what the dependencies of a script are. In my answer you'll find a script that uses Module::ExtractUse to list a script's dependencies. The only modules you'll need to install are Module::ExtractUse and Module::CoreList (if you don't already have it). You'll need to tweak the script a bit for your situation.

Upvotes: 8

Quentin
Quentin

Reputation: 944568

You can get a list of core Perl modules in the documentation. I don't think any of the ones you listed are core though.

There are various utilities that will install modules and trace dependancies for you automatically. cpan and cpan minus for example. local::lib will let you install them in a specific directory (that you can add to your PERL5LIB environment variable) if you want to avoid a system wide install (as root).

Note that some modules (such as those which use libxml) depend on non-Perl libraries to be installed.

If you really want to upgrade Perl, then you could look at perlbrew, which helps you have multiple versions of Perl installed side by side.

Upvotes: 2

Related Questions