in reply to check symbol table w/ dynamic name

The names of modules that are loaded with require or use are stored in the %INC hash so if a module is already loaded it cannot be loaded again.

Replies are listed 'Best First'.
Re^2: check symbol table w/ dynamic name
by skerr1 (Sexton) on Oct 17, 2006 at 04:47 UTC

    This worked great. Thanks for this clean solution. So, here is what it will look like:

    if (!$INC{ "$module.pm" }) { eval { require "${module}.pm"; } }

    Thanks for this!

    Shannon Kerr
      The point is that perl already does the test when you require a module so your test is superfluous.

        Point well taken. Thank you jwkrahn!

        Shannon Kerr
Re^2: check symbol table w/ dynamic name
by ammon (Sexton) on Oct 17, 2006 at 18:52 UTC
    if a module is already loaded it cannot be loaded again

    A minor nit-pick... a module can be re-loaded, if one is willing to do the requisite tomfoolery to make perl forget that it was already loaded.