开发者

How to install dependencies of a Perl script?

开发者 https://www.devze.com 2023-03-11 18:49 出处:网络
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.

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.


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.


Updating perl should be done through your package maganger. Module installation for perl from CPAN should be handled by the CPAN utility which is accessed general via command like with the command perl -MCPAN -e shell. CPAN will handle package requirements and proper installation procudure.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号