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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |