Isn't this approximately the same issue that base tries to deal with when it sets $VERSION to "-1, set by base.pm" if it's not already set, based solely on whether require returns true or not? And the same issue promptly ignored by advocates of parent? Those advocating parent seem to be (apologies if I misrepresent them - my goal is not a straw-man) that you Really Shouldn't Do That, So Please Stop It.
For example, if you try to:
you should be able to check the eval return code - if it's false, Foo failed to load. You pretty much can delete its namespace (but not anything beneath it).eval "use Foo;"
If it's a pre-loaded module, you pretty much have to assume compilation succeeded. If someone maliciously does a eval "use Foo;" and continues to ask you information about Foo even though it failed to compile, well, there's bupkiss you can do about it, I think. (This is a special case of tye's eval "$text; 1" since modules have to return true or they're considered to have failed compilation anyway.)if (eval "use Foo;") { # success } else { # failure (not found, failed to compile, who cares?) }
Introspection in perl is fine ... as long as you don't push the edge cases. Then it gets hard. I'm guessing Perl 6 will make this easier, but you'd know better than I :-)
In reply to Re: How Can I Know If a Package is "Real"?
by Tanktalus
in thread How Can I Know If a Package is "Real"?
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |