7

I don't have root access on a remote box I'm working with, so I'm using a combination of cpanm and local::lib as described here to install CPAN modules to my local directory on the box. Using cpanm, I assume cpanm Module::To::Update would install the newest version of the module in my local library.

Apparently, I don't need root access to upgrade my modules with CPAN, as I just tried it, and the upgrade went swimmingly. However, I'm still curious which version of the module Perl will use: the local version, or the default CPAN version? Or will it just use whichever is newer?

If this exists in perldoc or Stack Overflow, I'd appreciate that as well. I tried searching both, but I wasn't able to find it =/

Community
  • 1
  • 1
gempesaw
  • 329
  • 3
  • 12

2 Answers2

13

It uses the first one it finds when searching though @INC in order.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Oh. That's pretty simple. And presumably specifying `use Module Version` would let me pick which one I wanted manually. Thanks. – gempesaw Jan 18 '12 at 17:48
  • 4
    @dgempesaw - That presumption would be incorrect. If you need to load a particular module from a particular place, you'll need to hack at `@INC` or `%INC` (There are lots of ways to do that. How to do that would make a good follow up question). – mob Jan 18 '12 at 18:01
  • 4
    @dgempesaw, To find the module's version, Perl needs to execute the module. The module can't be un-executed if it's not the right version. – ikegami Jan 18 '12 at 18:13
  • 1
    @mob I see. I guess I need to read the docs regarding that more closely; I understand `@INC` enough to put my preferred directory first. – gempesaw Jan 18 '12 at 22:56
  • @ikegami That makes a lot of sense. Thanks. – gempesaw Jan 18 '12 at 22:57
1

you can check it by running this in linux:

perl -e 'use <module>; print $<module>::VERSION;'

kbang
  • 694
  • 9
  • 25