I've done a bit of searching, but I'm not getting the right results so thought I'd pose the question here.

I use Strawberry Perl on Windows and have a few different versions installed (5.8, 5.14, 5.18 32/64, 5.22). I manage them with a simple batch script that changes a directory junction from C:\strawberry to the appropriate Perl. Works great.

HOWEVER, when I switch from one to another, I "lose" all my modules - as expected. In other words, when I CPAN install a non-core modules to version 5.14 for example, when I switch to version 5.18, it isn't there - no shocker. ...

But could it be?

For some pure-perl modules, there should be *no* issue providing there are no backward-compatibility, new feature enhancements used. It'd save a bunch a time installing the same module 5 times for each of my 5 versions. I do have a %USERPROFILE%\perl directory and 'set PERL5LIB=%USERPROFILE%\perl\lib' in Command Prompt environment variables.

But are there implications? I'd install in 1 version of Perl so that CPAN database gets updated, but the other 4 wouldn't - what craziness could ensue? Has anyone done this or is there a better way that I'm missing? My searching keeps turning up local::lib - which is bundled in vendor/lib with Strawberry, but this sounds like what I'm already doing with PERL5LIB.

UPDATE: So I tried it - created a %USERPROFLE%\perl and %USERPROFLE%\perl5 directories. %USERPROFLE%\perl5 is a symlink (mklink in Windows) to a subdirectory in %USERPROFLE%\perl:

VinsWorldcom@C:\Users\VinsWorldcom> ls perl Directory of C:\Users\VinsWorldcom\perl [.] [bin] [..] CommonConfig.pm [5.08.8-MSWin32-x86-multi-thread] [lib] [5.18.1-MSWin32-x64-multi-thread] MyConfig.pm [5.18.2-MSWin32-x86-multi-thread] [5.22.2-MSWin32-x64-multi-thread] 2 File(s) 7,449 bytes VinsWorldcom@C:\Users\VinsWorldcom> ls -al [...] 01/19/2017 07:52 AM <JUNCTION> perl5 [C:\Users\VinsWorldcom\pe +rl\5.18.1-MSWin32-x64-multi-thread]

I set PERL5LIB:

PERL5LIB=C:\Users\VinsWorldcom\perl5\lib;C:\Users\VinsWorldcom\perl\li +b

Now for common pure Perl modules I want to share across all versions and I know will work on all versions, I install with:

cpan -j C:\Users\VinsWorldcom\perl\CommonConfig.pm Module::Name

... and it gets installed to %USERPROFILE%\perl, which has the ..\perl\bin in my %PATH%. Tested and it works fine.

Not sure of the future implications of this or if it's really the way to go. I don't use Perl all that often, but I do maintain a few modules and like to have different Perl version to test them on. Now instead of installing multiple copies of the same module into different Perl site directories, I install it once in a common place and all Perls can run against it and test. Limited use case, just wondered how other developers more experienced than I would handle something like this.


In reply to Common module lib across Perl versions on same system by VinsWorldcom

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.