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.


In reply to Re: Avoid using a module if it's not available by ww
in thread Avoid using a module if it's not available by perfluffle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.