Hm, I had a brainstorm, but not time to test it. Please correct me if any of this wouldn't work for your mod_perl issues (or if any of my assumptions are wrong).
Perl traverses @INC in order: as soon as it finds a module that fits a require or use statement, it acts on that and stops looking. (IIRC).
So, why not do this:
use lib 'my_modules/old_version'; use lib 'my_modules/new_version'; use MyModule '2.0'; #if you need version 2.
In theory, Perl would find version 1.0 in 'my_modules/old_version', and because it doesn't match, would keep looking, finding 2.0 in 'my_modules/new_version'. If you didn't ask for version '2.0', you'd see the 1.0 version first and use that.As ikegami points out below, this approach is flawed because Perl has to find and load the module before it knows the version. However, it looks like I was heading down the right path, as his approach (inverting the order of the paths in @INC) does work. Please ++ his post if you have spare votes!
I don't really know that use $VER works exactly that way... as I said this is a brainstorm. Thoughts?
In reply to Re: Howto implement versions of object instances
by radiantmatrix
in thread Howto implement versions of object instances
by pajout
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |