I set up a simple UNIVERSAL::VERSION method that allows me to search for an alternate versioned module ( e.g., one under development) instead of bailing out if the version number is too high. This works but not as cleanly as I'd like: I pull in the found module and the original. Is there any clean way to stop compilation of a given module without affecting the rest of the compile/run?

Related to this, I considered writing a true no by implementing a UNIVERSAL::unimport method that "unpollutes" the using module's namespace by removing aliased symbol table references. But it seems you can't undefine these. I tried code like this:
undef *{"${caller}::{$sym}"}{CODE};
but that gives me the error:

Can't modify glob elem in undef operator

I saw code in the Monastary that claimed to do it like this:
undef &{*{"${caller}::{$sym}"}{CODE}};
But this doesn't seem correct to me -- they're undefining the function, not the symbol table reference to it, right? That seems supported by the different error I get:

Unable to create sub named ""

A note in Advanced Perl Programming seems to indicate that you can't undo aliased symbol table names -- only use local so they revert back to their old values automagically. But I can't force a local here since the no is an optional, separate piece from the use .

Any ideas? I haven't found anything yet I can't do somehow in Perl, but this one has me stumped.


In reply to version based compilation by steves

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.