Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

"use"ing different versions of same perl module

by mjoyce (Novice)
on May 06, 2011 at 19:53 UTC ( #903439=perlquestion: print w/ replies, xml ) Need Help??
mjoyce has asked for the wisdom of the Perl Monks concerning the following question:

I'm hoping one of you has some advice for the following scenario: A newly developed perl script uses (and needs) the latest version of a shared library loaded into the script with "use". In addition, the script uses another perl module. The second, older perl module also uses the shared library, but an older version. The two versions of the shared library are not compatible. The new script calls a perl subroutine in the perl module, the module tries to access the function in the shared library, but fails--since it expected the older version of the shared library, and the new version had already been loaded.
BEGIN { unshift(@INC,".../sharedlib2.0") } use sharedlib; use perlmodule; #call subroutine in perlmodule dependent on sharedlib1.0"
BEGIN { unshift(@INC, ".../sharedlib1.0") } use sharedlib; sub perlsub { #call some function in sharedlib }

Comment on "use"ing different versions of same perl module
Select or Download Code
Re: "use"ing different versions of same perl module
by suaveant (Parson) on May 06, 2011 at 20:34 UTC
    If the module in question uses its own namespace I think you are SOL, unless you are willing to do some recoding. If it loads stuff into the current namespace only you could probably get away with it by loading it in the main program then deleting it from %INC, or do a 'do' in the sub module...

                    - Ant
                    - Some of my best work - (1 2 3)

Re: "use"ing different versions of same perl module
by John M. Dlugosz (Monsignor) on May 06, 2011 at 20:47 UTC
    Perhaps you can fix the spot that calls the old function that is no longer present or compatible. Did the library remove the feature completely, or more likely, just change the way it is accessed? Perhaps a spot change to the code will allow it to use the new library just fine.

Re: "use"ing different versions of same perl module
by Anonymous Monk on May 07, 2011 at 00:36 UTC
    • Module::Versions - Handle versions of loaded modules with flexible result interface
    • only - Load specific module versions; Install many
      That looks like the result of a search for Version Loading keywords, with no understanding of the OP's question. How does presenting information about a loaded version, or specifying which version should be loaded, do anything to address the problem?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://903439]
Approved by suaveant
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-08-22 23:22 GMT
Find Nodes?
    Voting Booth?

    The best computer themed movie is:

    Results (168 votes), past polls