Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

installing multiple versions of same module

by goonfest (Sexton)
on Apr 26, 2002 at 16:30 UTC ( [id://162326]=perlquestion: print w/replies, xml ) Need Help??

goonfest has asked for the wisdom of the Perl Monks concerning the following question:

Before I try it, I want to see if anyone has any insights.

I want to install version 2.0 of a perl module into a local directory. The concern is that version 1.0 of the same module already exists in the main PERL directory that I do NOT have write-access to.

Of course, I could always contact the system admin to upgrade the module, but I reckon it would not be high on his priority list.

In my script, I am using a standard header subroutine to pull in modules from both my local directory and the main PERL dir.

I am using a "use lib" statement for each directory, thus, what will @INC contain if it sees the same module name twice?

Are multiple "use lib" statments somehow prioritized, that is, will the last imported instance of a module overwrite any of those previously imported, or vice-versa?

I'm sure this same issue will arise again in the future. Any other ideas(not involving the sys admin) on what I can do?

Is their great risk of crashing anything? Mind you, I am doing this at work.

"Be proud, be a Goon"
  • Comment on installing multiple versions of same module

Replies are listed 'Best First'.
Re: installing multiple versions of same module
by jsprat (Curate) on Apr 26, 2002 at 16:42 UTC
    When you
    use lib '/path/to/lib'
    it is unshifted onto the front of @INC, so the directory you added at runtime will take precedence over the built-in @INC. HTH

      You could also use a BEGIN block, I believe:

      BEGIN { unshift @INC, /path/to/other/libs; }
Re: installing multiple versions of same module
by TheHobbit (Pilgrim) on Apr 26, 2002 at 18:12 UTC

    Hi,
    A better solution (at least on Unix) would be to define the PERL5LIB shell variable. See the ENVIRONMENT section in the perlrun man page.

    Cheers
    Leo TheHobbit
      For certain definitions of the word better ;-)

      Seriously, this does work, and it works on Windows too. Just not all the time. If you're the only one running the script, it will work fine.

      If someone else is running your script, he/she may not have the same environment that you do. Rather than force everyone to have the same environment variable set, I'd prefer giving them access to my module directory. Let the script handle the rest.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://162326]
Approved by George_Sherston
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-19 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found