Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: How can I prevent a module from being added to the %INC hash?

by jacques (Priest)
on Oct 04, 2006 at 03:29 UTC ( #576238=note: print w/ replies, xml ) Need Help??


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

One problem: What if you are putting the code above into a module and then use that module in a program? The %INC hash will contain all the modules that the program uses as well. And those modules will not be in the %INC hash when you assign it to %inc_copy.


Comment on Re^2: How can I prevent a module from being added to the %INC hash?
Re^3: How can I prevent a module from being added to the %INC hash?
by syphilis (Canon) on Oct 04, 2006 at 04:31 UTC
    What if you are putting the code above into a module and then use that module in a program?

    I might be missing something here, but it still seems to work ok:
    ## My_Foo.pm package My_Foo; BEGIN { use strict; use warnings; use Carp; use Digest::MD5; our %inc_copy = %INC; }; use Net::FTP; %INC = %inc_copy; 1;
    ## test.pl use Math::BigInt; use My_Foo; for(keys(%INC)) {print "$_: $INC{$_}\n"}

    Net::FTP and the modules it loads are still missing from %INC.

    Cheers,
    Rob
      When I run this, Net::FTP is there. Thanks though. You made me think about it in a new way.
        When I run this, Net::FTP is there

        Odd .. it's certainly not there for me on Win32, perl 5.8.8 - irrespective of which of the 2 modules is loaded first by the script.
        D:\pscrpt>perl test.pl XSLoader.pm: D:/perl58_M/5.8.8/lib/XSLoader.pm warnings/register.pm: D:/perl58_M/5.8.8/lib/warnings/register.pm My_Foo.pm: My_Foo.pm warnings.pm: D:/perl58_M/5.8.8/lib/warnings.pm Digest/base.pm: D:/perl58_M/5.8.8/lib/Digest/base.pm integer.pm: D:/perl58_M/5.8.8/lib/integer.pm Carp.pm: D:/perl58_M/5.8.8/lib/Carp.pm Math/BigInt.pm: D:/perl58_M/5.8.8/lib/Math/BigInt.pm strict.pm: D:/perl58_M/5.8.8/lib/strict.pm Exporter.pm: D:/perl58_M/5.8.8/lib/Exporter.pm vars.pm: D:/perl58_M/5.8.8/lib/vars.pm constant.pm: D:/perl58_M/5.8.8/lib/constant.pm Math/BigInt/Calc.pm: D:/perl58_M/5.8.8/lib/Math/BigInt/Calc.pm Digest/MD5.pm: D:/perl58_M/5.8.8/lib/Digest/MD5.pm overload.pm: D:/perl58_M/5.8.8/lib/overload.pm

        Oh, well ... such is life :-)

        Cheers,
        Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://576238]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2015-07-02 03:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (27 votes), past polls