in reply to How can I prevent a module from being added to the %INC hash?

Perhaps you should be using do instead of require or use? It does add the module to %INC, but since %INC is not checked, you can execute the "module" multiple times.

do should be used for "modules" with no package statement. require or use should be used with modules with a package statement.

# config.pl # --------- $var = 'test';
# main.pl # ------- use strict; use warnings; our $var; do 'config.pl'; print($var);

Replies are listed 'Best First'.
Re^2: How can I prevent a module from being added to the %INC hash?
by jacques (Priest) on Oct 04, 2006 at 03:33 UTC
    Is it possible to use a module another way? For example, putting a reference to a subroutine that uses a module into @INC? I think the docs indicate that only the reference is added to %INC. But I have never tried adding a code reference to @INC.

      Yes, read the module file and eval it.

      What are you trying to do? What's the end goal?

        It looks like ammon already solved it. I was attempting to do something similar to Devel::Loaded