perl modules

Posted on 2011-10-19
Last Modified: 2012-05-12
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?
Question by:netplus21
    LVL 76

    Assisted Solution

    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.

    LVL 26

    Accepted Solution

    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)".
    LVL 28

    Assisted Solution

    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.

    Author Comment

    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?
    LVL 26

    Expert Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now