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:

eval "use Foo;"
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).
if (eval "use Foo;") { # success } else { # failure (not found, failed to compile, who cares?) }
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.)

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.