Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

"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 }

Replies are listed 'Best First'.
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 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 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
[perldigious]: So I don't envy you mountain guys if you have to drive in the winter, even with tire chains.
MidLifeXis waves.
[stevieb]: man, I absolutely LOVE driving in the worst winter conditions. In the mountainous roads, there are extremely few (if any) other drivers. I love the challenge. I've been doing extreme off-road my whole life, and as I said, I'm always well...
[stevieb]: ...prepared for even the very worst
Discipulus seems a part of the globe very unfrindly with Kawasaki riders..
[thezip]: My doggies love it when it snows
[perldigious]: As long as you are a good "boy scout" stevieb, more power to you... but I like my Jeep, and don't like the idea of rolling it or crashing it in to anything. :-)
[thezip]: Me, not as much.
[perldigious]: Mine too thezip, especially my German Shepherd. He looks like he is about to die of heat exhaustion all summer, so he goes nuts when winter comes and he can play in the snow.

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2016-12-06 16:48 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (112 votes). Check out past polls.