Solved

Check for Module

Posted on 2000-05-04
4
166 Views
Last Modified: 2010-03-05
Is it possible to check if a module is installed and if so set $test = 1;

I want to check for LWP::Simple
0
Comment
Question by:mmcw
4 Comments
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 50 total points
ID: 2779178
Here is a very simple solution. I know that the ExtUtils::MakeMaker has functions to detect if modules are installed. You can also specify pre-requisites (ie other modules) needed for your own module.

$module_installed = 0;
$module_name = "LWP/Simple.pm";
foreach $dir ( @INC )
{
   ( -e "$dir/$module_name" ) and $module_installed = 1;
}
if ( $module_installed )
{
   print("$module_name is installed\n");
}
else
{
   print("$module_name is not installed\n");
}
0
 

Author Comment

by:mmcw
ID: 2779773
An other little question:
 What will happen if you try to use a module that is not installed:
example: use LWP::Simple;
0
 
LVL 84

Expert Comment

by:ozo
ID: 2779936
eval{ require LWP::Simple };
 $test = !$@;
 die $@ if $@;
0
 
LVL 3

Expert Comment

by:guadalupe
ID: 2782206
You will get an error saying that the module cannot be dound in any of the paths in the @INC array.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

19 Experts available now in Live!

Get 1:1 Help Now