there's one major difference, and i guess it wasn't quite clear from the first post.

you're still useing the modules at the beginning, even though they're wrapped in an eval. and they're wrapped in an eval for a reason -- you're handing the scripts off to folks who may or may not have that resource.

the issue, with more context:

sub do_stuff { ### some stuff eval "use Foo::Bar::Baz;"; die if $@; ## do stuff with the imported functions }
in some cases, the same  eval "use Foo::Bar::Baz;"; will end up in a different sub, same module. . .

there's no 'hand off to client' - these are all internally-developed modules. . .

i know that it's perfectly legal perl syntax . . . . it just doesn't sit quite right with me . .

UPDATE: the thing is, and i haven't made it clear, is that the module being used in the eval string is NOT being used on 'initialization' ( for lack of a better word ). there's no 'use Foo:Bar::Baz;' at the beginning for the module. . .

and i've been looking to see if there were any other issues than 'bad style'.


In reply to Re: Re: runtime "use" statements via string eval by geektron
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.