Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

installing modules

by baxy77bax (Chaplain)
on Aug 10, 2010 at 11:00 UTC ( #854000=perlquestion: print w/replies, xml ) Need Help??
baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:


well here is the problem. let say i would like to install some module :

And this module depends on 10 different modules , and some of those modules depend on several other modules ... you get the picture.

to install everything what i would do is, i would use cpan and run the instalation of module and cpan would ask me do i want to install all the dependencies and i would say yes. ok. so my question is how would i do this automatically, so when i set my perl program on my machine and start it for the first time, then i would like that my program identifies all required modules and if they do not exist ask the user would he or she would like to install them .

BEGIN { my @modules; eval{"use Data::Dumper;"}; push(@modules,"Data::Dumper") if $@; eval{"use Getopt::Long;"}; push(@modules,"Getopt::Long") if $@; eval{"use Term::ReadLine;"}; push(@modules,"Term::ReadLine") if $@; eval{"use Term::ReadKey;"}; push(@modules,"Term::ReadKey") if $@; eval{"use File::Copy;"}; push(@modules,"File::Copy") if $@; eval{"use File::Path;"}; push(@modules,"File::Path") if $@; eval{"use Cwd;"}; push(@modules,"Cwd") if $@; eval{"use IO::Socket;"}; push(@modules,"IO::Socket") if $@; eval{"use bignum;"}; push(@modules,"IO::Socket") if $@; eval{"use Term::ANSIColor;"}; push(@modules,"Term::ANSIColor") if $@; die "Some modules are missing, please install the following modules + and try again:\n -- " . join("\n -- ",@modules) if @modules; }
when the user says YES then connect to the net and identify all dependencies of all modules and download and install everything.

The reason im avoiding cpan interface is because i received some complaints that cpan is too hard to install and that it asks too many questions that a regular MSOffice user doesn't understand. so what i would like to do is to make a script that would identify all necessary dependencies and the when user says 'yes' to install them locally in some folder from where my program knows to read them. without any knowlage what is happening behind the curtains

use lib "./Lib";
are there any examples, or did anyone already done something in this area so i don't reinvent the circular thing on the car or bike or ....


Replies are listed 'Best First'.
Re: installing modules
by Corion (Pope) on Aug 10, 2010 at 11:09 UTC

    There is App::FatPacker to collect all prerequisites and paste them into your main script. Also, PAR::Packer collects the prerequisites somehow.

    I guess the most common approach is to run your program and at the program exit, dump %INC, which contains all loaded modules:

    use Data::Dumper; END { print Dumper \%INC; };
Re: installing modules
by marto (Bishop) on Aug 10, 2010 at 11:10 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://854000]
Approved by Corion
Front-paged by Corion
[thezip]: How goes it, Corion?
[Corion]: thezip: Quite good, after a one week vacation in the sun ;)
[Corion]: I hope you're well too!
[thezip]: Where did you go? We've already set a record for all-time February rainfall here.
[Corion]: thezip: The Canary Islands - they have a constant climate
[Corion]: Maybe a bit too many old people, but for some do-nothing vacation for R&R exactly the right thing ;)=

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-02-23 17:01 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (349 votes). Check out past polls.