On Sat, Sep 24, 2005 at 02:13:46PM -0400, Randy W. Sims wrote: > Is there a way to make C<require> or C<use> fail without manipulating > @INC or hiding the physical file? Or more generally, how do you test all > branches of constructs like: > > if ( eval {require Foo} ) { > useFoo(); > } elsif ( eval {require Alternate} ) { > useAlternate(); > } else { > fake_it(); > }
Override CORE::GLOBAL::require. However, working out all the little nuances and buglets in such an approach is fraut with peril. Leaving the error message unaltered (as to the file and line number of the require), maintaining backwards compat (the behavior of CORE::GLOBAL::require changed between 5.6 and 5.8) and avoiding circular references (some of the magic around CORE::require appears to be broken) is tricky enough that I couldn't get it to work fiddling around for about 10 minutes. -- Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern Insulting our readers is part of our business model. http://somethingpositive.net/sp07122005.shtml