[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • 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?
0
netplus21
Asked:
netplus21
3 Solutions
 
arnoldCommented:
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.

 
0
 
wilcoxonCommented:
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
q

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)".
0
 
FishMongerCommented:
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.
0
 
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?
0
 
wilcoxonCommented:
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.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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