# from Matisse Enzer
# on Thursday 18 October 2007 13:31:

>So, what is Best Way?

Module::Finder ?

>And how about those references in @INC?

Best to not mess with them unless it is acceptable to actually load the 
module.  Even then, you're very likely to end-up with a buggy 
reimplementation of require (like Log::Log4perl) causing strange bugs 
when interacting with PAR and etc.

If your @INC has refs in it and all of the directories before the ref do 
not contain Foo/Bar.pm, you should just eval {require("Foo/Bar.pm")} 
because of some particulars of how the ref-in-inc thing works.

E.g. if it is a coderef, it can set $INC{"Foo/Bar.pm"} to an actual 
filename, but isn't required to do so.  If it doesn't, require() will 
set that value to equal the ref.  Note that the ref could be a subref, 
arrayref, or object.  See perldoc -f require.

So, after you require("Foo/Bar.pm") you can look in $INC{"Foo/Bar.pm"} 
and try -e on the off chance that you actually got a real filename as 
an answer.

In short, you might as well skip the refs unless you want to deal with 
the possibility of "we can load the module, but can't say where we 
found it".

--Eric
-- 
hobgoblin n 1: (folklore) a small grotesque supernatural creature that
          makes trouble for human beings
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------

Reply via email to