Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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:

hi,

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

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 A.pm 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 ....

thnx

Comment on installing modules
Select or Download Code
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 (Chancellor) on Aug 10, 2010 at 11:10 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://854000]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (21)
As of 2014-07-11 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (232 votes), past polls