I have a Perl script that has two dependencies that exist in CPAN. What I'd like to do is have the script itself prompt the user to install the necessary dependencies so the script will run properly. If the user needs to enter in some kind of authentication to install the dependencies that's fine: what I'm trying to avoid is the following workflow:
Run script -> Watch it fail -> Scour CPAN aimlessly -> Lynch the script writer
Instead I'm hoping for something like:
Run script -> Auto-download script dependencies (authenticating as necessary) -> Script succeeds -> Buy the script writer a beer
Can this be done?
You can probably just execute this from inside your script.
perl -MCPAN -e 'install MyModule::MyDepends'
Each of the standard build paradigms has their own way of specifying dependencies. In all of these cases, the build process will attempt to install your dependencies, automatically in some contexts.
In
ExtUtils::MakeMaker
, you pass a hash reference in thePREREQ_PM
field toWriteMakefile
:In
Module::Build
, you pass a hashref to thebuild_requires
field:In
Module::Install
, you execute one or morerequires
commands before calling the command to write the Makefile: