The way it's done now allows for the mutual inclusion of two modules. The way you suggest would cause an infinite loop.
I didn't understand what you meant by this at first -- but after considering it, I think you're speaking of why %INC is set first. I agree. I wasn't suggesting changing it -- I just hadn't fully understood the consequences of what a failing "eval require" really does.
More broadly, I think it shows a limitation of eval as an exception mechanism for module loading. If Foo or Bar die during require, they could easily leave the symbol table in an unstable state.
As for your example, I'm actually not concerned with circumventing the %INC check. I just need to know if a module is installed (and working) -- and since I might ask that in more than one place in the code, some sort of cache of the first answer I get doing a require was what I needed.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re^2: How not to check if a module is installed
by xdg
in thread How not to check if a module is installed
by xdg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |