Search code examples
linuxperl

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.


Solution

  • 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.