Wednesday, March 23, 2016

How-to: Can't locate IPTables/IPv4/IPQueue.pm

In this article, we will cover the following topics:
  • How to resolve Perl module missing issue
  • Know about CPAN (Comprehensive Perl Archive Network)
  • Learn how to configure CPAN module (i.e, CPAN.pm)

Missing Perl Module


When a Perl script using IPTables::IPv4::IPQueue[1] was executed:
BEGIN
{ push @INC, "/scratch/perf/.../perl/5.8.8/x86_64-linux-thread-multi"; } use strict; use warnings; use IPTables::IPv4::IPQueue qw(:constants);

It threw the following error message:[6]
  • Can't locate IPTables/IPv4/IPQueue.pm in @INC (@INC contains:,,,
A Perl module is the Perl equivalent of the class in OOP. It defines how its source codes are packaged (much like Java packages) using namespaces. Its file structure mirrors the namespace structure. For instance, IPTables::IPv4::IPQueue could locate in your file system somewhere like:
  • /usr/local/lib64/perl5/auto/IPTables/IPv4/IPQueue
To resolve the missing module issue, you need to install it by entering:
cpan[1]> force install IPTables::IPv4::IPQueue
But, before you do it, make sure you understand the following sections first.

CPAN (Comprehensive Perl Archive Network)


CPAN is a software repository of over 150,929 modules written in the Perl programming language. The modules can be downloaded from metacpan.org and also from mirrored sites worldwide. The resources found on CPAN are easily accessible with the CPAN.pm module.

From metacpan.org home page, you can search for any Perl Module you need. For example, enter "IPTables::IPv4" in the search field. You will find the documentation for IPTables::IPv4 here.

CPAN Module (CPAN.pm)


The resources found on CPAN are easily accessible with the CPAN.pm module. If you want to use CPAN module, you use CPAN shell, which provides an interactive mode, in two ways:

perl -MCPAN -e shell
--or--
cpan

Configuration Steps


If you want to use CPAN.pm, lots of things have to be configured. So, when you use it the first time, you will be prompted to configure them. After the configuration, don't forget to commit by entering:

cpan[19]> o conf commit

to make the configuration permanent, which configuration data will be logged into below file:
  • /usr/share/perl5/CPAN/Config.pm

Only one CPAN process can be run at a time and this is protected by a mechanism using below lock:
  • /root/.cpan/.lock


How to Connect to the Internet behind a Proxy


After the first-time configuration effort, you can still modify configured data by entering:
cpan[20]> o conf init
Then you will be asked if you like to configure as much as possible automatically or not. Without the trouble of going through all configuration steps again, you can also specify which data to be configured. For example, if your server is behind a proxy server, you may run into the following issue:
  • As you did not allow me to connect to the internet you need to supply a valid CPAN URL now.


To work around, you can configure a proxy for CPAN by entering:[4,5]

cpan[21]> o conf init /proxy/
If you're accessing the net via proxies, you can specify them in the CPAN configuration or via environment variables. The variable in the $CPAN::Config takes precedence.
Your ftp_proxy? []

At the "Your http_proxy? " prompt, we have entered the following:
  • http://146.xx.xx.29:80

and it works fine afterwards. Besides proxy configuration, you may also want to configure a urllist to specify which mirror(s) to use for downloading:

cpan[22]> o conf init urllist

There are 235 registered sites around the world make up the N part of CPAN (the Network), you can find the full list here.

1 comment:

Unknown said...

Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating Hadoop Admin Online Training