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?

<-radiant.matrix->
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law

In reply to Re: Howto implement versions of object instances by radiantmatrix
in thread Howto implement versions of object instances by pajout

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.