http://www.perlmonks.org?node_id=691815


in reply to Avoid using a module if it's not available

Maybe I'm looking at this the wrong way, but your comment,

I have a list of modules I want to use, but only if they're available (i.e. installed on the system the script is running on and included in @INC). If they're not available, I want the code that calls them to be skipped. .... I have about ten different modules I need to use or not-use based on availability.

has me perplexed.

What will your script do (aside from skipping calls) when it runs on a system lacking the modules?

Are you going to reinvent the wheel for each missing module (on who knows how many systems)? Are you going to lift the code from pure perl, non-core modules and insert it in your package? Is one of those or some other workaround in your plan, so your script will function without regard to the target system's lack of one or more of your ten modules.

And how do you plan to distribute your script? (My suspicion is that if you can distribute it and have the sysadmin/owner agree to employ it, you can find a means to get the missing modules installed.)

In short: You've stated your perceived problem clearly, but is it the real problem? (Cf: jdporter's excellent XY Problem.