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?
For example, compare the difference between these two commands:
perl -e'BEGIN{ eval "use Net::FTP;" } print %INC'
and
perl -e'BEGIN{ local %INC = %INC; eval "use Net::FTP;" } print %INC'
The only difference between the two is the localization of %INC in the BEGIN block.
Of course, doing an eval on the string is slow. The OP might want to use a require inside a BEGIN block, instead:
BEGIN { # Hide the fact that our module was imported. local %INC = %INC; require Net::FTP; # call import() if necessary }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How can I prevent a module from being added to the %INC hash?
by jacques (Priest) on Oct 04, 2006 at 07:13 UTC | |
|
Re^3: How can I prevent a module from being added to the %INC hash?
by sgifford (Prior) on Oct 04, 2006 at 19:43 UTC |