Well, I can't say whether or not it's completely ideal, but I've started using something like this to ensure that I've got all the modules I need:

#!/usr/bin/perl -wT use strict; $|++; eval( "use MIME::Lite;" ); die "Module Configuration Error: $@" if $@; # and so on.

Since I'm writing scripts for servers that I don't have have access to, I'm forced to test them on my personal resources, get them working, and then toss them into the Black Hole known as "Security Testing" in the company I work for.

Personally, I like being able to tell the "experts" that they need to "tail their error log" in order to tell me what what wrong. *grin*

A recent check via CB seemed to think this was an okay approach. As always, YMMV...

Update: In reply to geektron's reply below:

Ah, I get you. Yeah, that feels weird. To my mind, you should localize your uses and your uses/requires into a configuration section before doing any work. If it's gonna fail, get it to do so before you waste any time...unless you have a problem with people, like, y'know, deleting modules from underneath you. (And if that's going on, well, friend, you've got more issues than concurrency ones, if you know what I mean.)

I spent about an hour poring over various perldoc entries and the closest I can find to anything that's documented is from perlmod,

"You can switch into a package in more than one place; it merely influences which symbol table is used by the compiler for the rest of that block."

Not entirely related, but if you read it obliquely, I think it suggests that there's no real benefit to using the module multiple times...unless (for some strange reason) you're modifying values in the module itself. Even then, I can't see how this would possibly make any difference. If you've used the module once, you've got to have a little bit of faith that it still exists within a few clock cycles.

Thoughts? Feedback?

--f

Update #2: Fixed a rather nasty typo that damian1301 caught. (Thanks.)


In reply to Re: runtime "use" statements via string eval by footpad
in thread runtime "use" statements via string eval by geektron

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.