in reply to Howto implement versions of object instances
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Howto implement versions of object instances
by ikegami (Patriarch) on Nov 15, 2005 at 18:03 UTC | |
by pajout (Curate) on Nov 16, 2005 at 09:34 UTC |