I want to distribute my Perl application which have one CPAN dependency. Can I include a check for this dependency when somebody starts the application. Through command line argument or inside perl directly?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Is this a pure Perl module with no other dependencies?
I’d just package it with my code. Heck, you can even just append it to your file, if you prefer.
If this is a bit more complex, that is, there are a dozen of required modules that must be installed, and there is some compilation that is required, you’ll have to use CPAN to download it. There is a CPAN::AutoINC which is suppose to download and install any modules you need from CPAN when the module is required and not in the
@INCpath.However, my experience has been that you end up with a mess ‘o worms. A user might start to run your program thinking it’ll run for a a minute only to discover that they’re spending 20 minutes downloading, compiling, and testing prerequisite modules when they really don’t have time.
It’s better just to fail, and give a good explanation of what is required. The user might prefer to run
cpanas root, so it’s available for everyone on the machine. Or, maybe they need to ask a system admin to do it for them.I’ve found I can do something like this:
It explains what is the issue, and what needs to be done and gives the user a choice to either go ahead with the install, or ask someone else to do it for them.