Very cool. That works. Assign everything but the piece you don't want. That's one I didn't try. And it's so obvious once you see it.

Since you solved that one, how about the bigger question that started me down this path: When a module's VERSION method is called, is there a way to stop compilation of the module at that point and switch to another one? This all started with an experimental piece of code like this:

use Carp; sub UNIVERSAL::VERSION { my $class = shift; my $wanted_version = shift; my $fixed_version = $wanted_version; my $caller = caller(); my $version_class; $fixed_version =~ s/\./_/g; $version_class = "${class}_${fixed_version}"; eval <<"END_EVAL"; package $caller; no $class; require $version_class; $version_class->import(); END_EVAL croak "Version $wanted_version of $class not found ($version_class +): $@" if ($@); }

I believe this works because the eval code runs after the BEGIN code (from use) that invoked the VERSION method. So the versioned copy of the module loads after, overwriting aliases. But ideally I'd want to just stop compilation of the non-versioned module so there are no BEGIN, CHECK, END type blocks pulled in.

Thanks for the help on the one above. Most people I start talking typeglobs and symbol tables to just glaze over.


In reply to Re: Re: version based compilation by steves
in thread 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.