micceo has asked for the wisdom of the Perl Monks concerning the following question:

Hi , i am a newbie to perl , i want to do the following , we have a code in perl which requires the use of many external modules.

Is there a way where i can install all the modules required into a particular directory and make perl point to it . Like a plug and play feature .

I tried looking at local::lib , but could not make much out of it, some help will be appreciated

Regards Ravi

Replies are listed 'Best First'.
Re: self containing folder of modules
by moritz (Cardinal) on Sep 20, 2011 at 08:43 UTC

    local::lib does what you want, and the processes of point perl towards the module directory consists of setting the PERL5LIB environment variable (and PATH if the distributions also install scripts), as shown in the SYNOPSIS. The same can be achieved with the -I command line argument.

    The other environment variables are only needed for installing the modules/distributions into the right directory, and not necessary for just using the modules.

    If you describe where you got stuck, it would be easier to help you.

    There are other alternatives, like PAR::Packer and other packers, like cava.

      these are the modules i want to use
      use Archive::Tar; #use Authen::Radius; #install Data::hexdumo use bytes; # Do everything in this function by bytes, + not (possibly multibyte) characters. use Carp; use CGI ':standard'; #use CGI for easy web generation use Compress::Zlib; use Config::Tiny; #use Crypt::SSLeay; #install all libraries first use Cwd; use Data::Dumper; #use Device::SerialPort; use Digest::MD5; use DirHandle; use Encode; use enum qw(BITMASK:TYPE_ NUMERIC STRING ARRAY); use Exporter; use Fcntl; use File::Basename; use File::Copy; use File::Find; use FileHandle; use File::Path; use File::Spec (); use Frontier::RPC2; use Getopt::Long; #use Gtk; use HTML::Entities; use HTML::Form; use HTML::PullParser(); use HTML::TokeParser; use HTTP::Cookies; use HTTP::Daemon; use HTTP::Date qw(time2str); use HTTP::Headers; use HTTP::Message; use HTTP::Request; use HTTP::Request::Common; use HTTP::Response; use HTTP::Status; use IO::Dir; use IO::File; use IO::Handle; #use IO::Pty; use IO::Scalar; use IO::Select; use IO::Socket; use IO::Socket::INET; #use IO::Socket::SSL; #use IO::Tty; use IPC::Open2; use IPC::Open3; use IPC::Run::Debug; use IPC::Run qw(run); use IPC::Semaphore; #use IPC::Shareable; #use IPC::Shareable::SharedMem; use IPC::SysV qw(IPC_RMID); use JSON::XS; use List::Util qw(first); use LWP; use LWP::ConnCache; use LWP::MediaTypes qw(guess_media_type); use LWP::UserAgent; use MIME::Base64; use Net::Cmd; use Net::Config; use Net::DNS; use Net::DNS::RR; #use Net::Frame::Layer::TCP; #use Net::Frame::Simple; use Net::FTP; use Net::FTPServer::Full::Server; use Net::MySQL; use Net::Nessus::Client; use NetPacket::Ethernet qw(:strip); use NetPacket::IP; use NetPacket::TCP; use NetPacket::UDP; use Net::Pcap; use Net::Pcap::Reassemble; use Net::Ping; use Net::SMTP; use Net::SNMP; use Net::SNMP::Security::USM; use Net::SNMP::Security::USM v3.0.0; use Net::SOCKS; use Net::SSH::Perl; use Net::SSLeay; use Net::Telnet; use Nmap::Scanner; use PDF::API2; use POE; use POE::Component::Client::TCP; use POE::Driver::SysRW; use POE::Filter; use POE::Filter::Line; use POE::Filter::Stream; use POE::Kernel; use POE::Loop::Event_Lib; use POE::Loop::PerlSignals; use POE::Resources; use POE::Session; use POE::Wheel::FollowTail; use POE::Wheel::ReadWrite; use POE::Wheel::SocketFactory; use POSIX qw(:fcntl_h); use Scalar::Util qw(looks_like_number); use SOAP::Lite; use Socket; use Storable; # for dclone use String::CRC32; use String::Random; use Switch; use Symbol; use Sys::Hostname; use Term::ANSIColor qw(:constants colored); use Text::Balanced (); # core use Text::ParseWords qw(quotewords); use Time::gmtime; use Time::HiRes; use Time::Local; use Tk; # or one of several others use UNIVERSAL (); use URI; use URI::Escape; use utf8; # required for 5.6 #use Win32; #use Win32API::File qw( :ALL ); #use Win32::GuiTest qw(:ALL); #use Win32::OLE; #use Win32::OLE::Const 'Microsoft Excel'; #use Win32::OLE::Const 'Microsoft Outlook'; #use Win32::OLE('in'); #use Win32::OLE::Variant; #use Win32::Process; #use Win32::WinError; use XML::DOM; use XML::SAX; use XML::SAX::Writer; use XML::Simple;
      they may have circular dependencies , so i want to create a folder with all these modules installed , so just make perl pick libraries from that folder. now as there might be dependencies , if i install a module into local folder, the other module might still show dependency error??

        For quick and easy module installation, also see the -L option to cpanm.

Re: self containing folder of modules
by Anonymous Monk on Sep 20, 2011 at 08:32 UTC