Can't locate loadable object for module SNMP in @INC

First of all i am new to perl, but i've had experience in other languages like c and vb. I am running win2k3 server, IIS 6.0, and ActivePerl 5.8.2. I am trying to execute this script located here:

The is where i'm having problems. When i execute the script(ups-battery-status) i get this error:

Can't locate loadable object for module SNMP in @INC (@INC contains: C:\Perlib C
:/Perl/lib C:/Perl/site/lib .) at C:/Perl/lib/ line 45
Compilation failed in require at C:/Perl/lib/ line 45.
BEGIN failed--compilation aborted at C:/Perl/lib/ line 45.
Compilation failed in require at C:\Perl\bin\ line 78.
BEGIN failed--compilation aborted at C:\Perl\bin\ line 78.

Also, whenever i see that i am missing a module or file of course i download it. Although how do i point the file to my windows directories?
For example, how do i make use Mail::Send; point to where put it, c:\perl\lib\mail\  ?
Where should i be extracting the files needed for the scripts? in my c:\perl\lib directory?

Who is Participating?
jmcgConnect With a Mentor OwnerCommented:
One more point of clarification:

When you say

use lib 'C:/Perl/lib/Mail';

use Mail::Send;

the interpreter is going to be looking in the wrong place. In looking for the module, the namespace qualifiers (the part before the ::) become part of the path for the filename, so the file -- if it were to be found -- would have to be


because one Mail comes from the INC entry and another is supplied as part of the module name. You really should only have the names of top-level library directories in @INC so that really should have been:

use lib 'C:/Perl/lib';

What method do you use to "dounload" AND install the modules?  You should be using ppm.

ppm install Net-SNMP

That will download and install the module in the proper directories.

Or, you can use the CPAN module to install the modules.

perl -MCPAN -e "install Net::SNMP"

In eather case, you can enter the interactive shell then install.

install Net-SNMP

perl -MCPAN -e shell
install Net::SNMP
Looking over the code for the ups-battery-status module, I see that it's designed to run on a UNIX system.  You're probably going to need to modify it to run properly on Windows.
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

djsuperzAuthor Commented:
Being new at perl, will it run fine on Linux? What linux software do you recommend?
It should run fine on Linux but you'll need to make sure you install all of the dependency modules.  For example, looking over some of the modules source code, you need both Net::SNMP and SNMP modules.  Since the last update to the SNMP module was in Feb 2001, it’s probably not being maintained any longer.   You’ll also need to make the proper adjustments in them to accommodate for any discrepancies in the paths used in their config section(s).

On another note, since most of these modules are not part of the base install of Perl, they are normally installed in c:\perl\site\lib\.  When installing via ppm or perl –MCPAN, the install path is handled automatically.  If you downloaded a tar or zip file then you may need to manually copy them to their proper locations.
The @INC array works much like a PATH statement -- it tells Perl where to look for modules your script requires.  To avoid this error, you can put the module in one if the indicated directories (C:\Perlib, C:/Perl/lib, or C:/Perl/site/lib) or add your preferred directory to the @INC array:

    unshift (@INC, "C:\\perl\\lib\\mail\\");
Looking at what I wrote, it'd be better to leave the actual name of the module off, and just provide the path:

    unshift (@INC, "C:\\perl\\lib\\mail");

You can also achieve the same thing by the "use lib" method.  Just include at the top of your program this line before calling any modules:

use lib "C:\\perl\\lib\\mail";

Hope this helps!
It should be noted that the methods mjcoyne showed are for accessing modules that are installed outside of the default @INC directories.  The modules that we are working with here (SNMP and Mail::Send) are standard modules that should be installed via ppm or –MCPAN and will be found in @INC (C:/Perl/site/lib), if/when installed properly.

In this case it appears that the Mail::Send module was not found because djsuperz manually created the subdirectory and copied the module into it.  Normally this would not be a problem but remember case makes a difference to Perl.

C:/Perl/site/lib/mail  is not the same as C:/Perl/site/lib/Mail

Which means when you have

use Mail::Send;

Perl is looking for

   C:/Perl/site/lib/Mail/  (or C:/Perl/lib/Mail/


   C:/Perl/site/lib/mail/ (or C:/Perl/lib/mail/

Additional note to mjcoyne;

It would be better/cleaner to use forward slashes and single quotes.

use lib 'C:/Perl/lib/Mail';
I agree with all of FishMonger's points -- you should be installing things in their proper (read "expected") place.  However, you did ask " how do i make use Mail::Send; point to where [I] put it, c:\perl\lib\mail\", so I answered that...  Also, if you're were writing a limited use or special purpose module of your own, you might want to put it somewhere non-standard; if so this is how you do it...

>It would be better/cleaner to use forward slashes and single quotes.

Also agree completely -- force of a (bad) habit of mine...:).

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.

All Courses

From novice to tech pro — start learning today.