Reputation: 51
I am using Windows operating system and i have my running perl script.In my script Path::Class::Rule
module i am using .
My script is not able to run, on some of the system, because the above mentioned module is not installed.So i need to add a logic for pre-setup which will check whether all the required module is installed on the system or not if not then install the module first then do rest of the processing.
I am trying to install the module using system subroutine
but perl modules are not getting install.
Here is the code which i am using:
use warnings;
use Path::Class;
use Path::Class::Rule;
use Cwd qw();
use File::Path qw(make_path);
use File::Copy;
system ("ppm install Path::Class::Rule");
can any body help me out how to add the logic ?
Upvotes: 1
Views: 5142
Reputation: 107
or use perl -MCPAN -eshell
to use the install [module] from the command line
Upvotes: 0
Reputation: 6808
Your logic is flawed -- your code should not check for missing modules (it will be done on each run).
You can install CPAN modules with following command
perl -MCPAN -e 'install [MODULE]'
You could use batch or cmd installation file to install all required modules.
You could use perl installation script which will verify what modules are missing and install them.
NOTE: Your post is not clear if you refer to install script or not.
You need read documentation 'perl module installation'
What's the easiest way to install a missing Perl module?
Upvotes: 0
Reputation: 13664
Look at this:
use Path::Class::Rule;
...;
system ("ppm install Path::Class::Rule");
You're trying to use
the module before installing it.
Try something like this:
BEGIN {
eval { require Path::Class::Rule }
or system("ppm install Path::Class::Rule");
}
use Path::Class::Rule;
Though personally I think a better idea is something like:
BEGIN {
eval { require Path::Class::Rule }
or die "Missing Path::Class::Rule. See README for installation instructions.\n";
}
use Path::Class::Rule;
Upvotes: 2