• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

perl modules

Hi, I have a perl script which has the following modules listed at the beginning:

use CGI::Carp qw( fatalsToBrowser );
      use DBI;
      use CGI qw( :standard );
      use CGI::Cookie;
      use Crypt::CBC;
      use lib qw( . );
      use POSIX qw( ceil );
      use List::Util qw( shuffle );
      use strict;

How can I check to see if all the above exist on a linux server, and that they are in the correct locations, with the correct permissions and ownerships?
3 Solutions
perl -e 'use CGI;' if no error it can be found
or you can use all in a single perl file if they can not be found you will get an error if they can be found the script will execute and exit without any error.

By default, the modules should be installed under /usr/local/lib/perl/site_perl/ (but that could vary by OS version/flavor).

As an alternative to arnold's suggestion, you could check using CPAN.

perl -MCPAN -e shell
m module_name
m another_module_name

The important entries are CPAN_VERSION (showing the latest non-beta release), INST_VERSION (what version you have installed), and INST_FILE (where the module is installed).  If it is not installed, you will see "INST_FILE    (not installed)".
DBI and Crypt::CBC are the only modules in that list which are not core modules.  If any of those core modules are unavailable, then your perl installation is broken and is in my mind equal to trying to drive a car with a severely blown head gasket.  For testing non core modules, I'd agree with the approach that arnold suggests.
netplus21Author Commented:
Great, thanks for the answers, I tried both  methods and all the modules are installed.

wilcoxon: I noticed the INST_FILE descriptive for the modules. Is this always the path which a script will go to in order to access a module? (for example in cases where there are multiple installations of the same module)

Also, if I could locate the module using the method you showed, is it certain that a script using the module would be able to locate and access it as well?
Yes, INST_FILE is always the path to the installed module.  I'm not sure what will happen if multiple versions are installed (I don't currently have such a case).

Yes, unless something is very strange with your perl install, if CPAN says a module is installed, perl scripts should always be able to use the module.  The one possible case I can think of where it might fail is if someone goes in and manually removes the file (I believe (not positive) that CPAN checks the install list/db rather than manually locating the files) - again, this is not something that should happen.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now