Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: Testing for a module's presence

by sgifford (Prior)
on Feb 07, 2005 at 04:45 UTC ( [id://428568]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Testing for a module's presence
in thread Testing for a module's presence

The thing I don't like about searching @INC is that it's re-implementing a part of Perl based on how it works right now. A future version of Perl could use a different scheme for locating libraries. For example, it could add a new type of arch directory, hash the directories to avoid too many modules in the same directory, add a new .pmz type for compressed modules on disk-poor systems, or load code across the network. A user could even provide their own copy of the lib module and/or the require function to implement those sorts of things right now.

In the face of possible changes to the module search algorithm, actually asking Perl to find the library and say whether it worked or not will always work, while re-implementing the library search yourself will only work for as long as nothing changes.

Using a module designed to do this, as others have suggested here, is a good compromise.

As for the cross-platform concerns, I have used fork on ActiveState Windows; it seems like a lot would break without a working copy of this function. And POSIX::_exit seems to avoid your other concerns.

Also, to clarify, I don't think using fork will be particularly fast; just faster than using system, which was my original proposal.

Replies are listed 'Best First'.
Re^4: Testing for a module's presence
by nothingmuch (Priest) on Feb 10, 2005 at 10:12 UTC
    Or maybe add support for code refs in @INC... ;-)

    I'm even using this in Devel::FIXME. Fun fun fun!

    -nuffin
    zz zZ Z Z #!perl

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-24 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found