Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: how to improve: use MODULE VERSION LIST

by 1nickt (Canon)
on Jan 07, 2017 at 01:09 UTC ( [id://1179108]=note: print w/replies, xml ) Need Help??


in reply to how to improve: use MODULE VERSION LIST

You could:

  • Alter @INC at program compile time rather than perl compile time, so your CTB users do:
    use lib '/usr/foss/packages/foss-perllib';
    which unshifts your directory onto the front of @INC.

  • Edit: the following does not work, I was mistaken as shown by choroba and ikegami. (While there are no doubt gory reasons why it is so, it seems an uncharacteristic lack of DWIMery from Perl ...) Continue with the @INC you've compiled in, and instruct your CTB users to require a specific version, e.g.:
    use autodie 2.29;
    which ensures that perl will keep looking until it finds the specified version (in your directory).

Hope this helps!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: how to improve: use MODULE VERSION LIST
by ikegami (Patriarch) on Jan 09, 2017 at 14:23 UTC

    That's not true. In order to determine the version of a module, Perl must first load it. As such, Perl can't load anything but the first module of a given name it find, even if a version if specified.

    $ cat Foo/Mod.pm package Mod; $VERSION = 1; 1; $ cat Bar/Mod.pm package Mod; $VERSION = 2; 1; $ perl -e'use lib qw( Foo Bar ); use Mod 2;' Mod version 2 required--this is only version 1 at -e line 1. BEGIN failed--compilation aborted at -e line 1.
Re^2: how to improve: use MODULE VERSION LIST
by smile4me (Beadle) on Jan 07, 2017 at 19:03 UTC

    Thanks 1nickt.

    Yeah, I have been coaching folks to do the use lib 'new dir' technique, to rearrange @INC. Which works okay when used in combination with "use autodie 2.29".

    What bothers me most is that I have to manipulate @INC at all, especially when specifying a VERSION that I'm looking to use. The real problem is that Perl will not keep looking for the newer version of a module, if an older one is found earlier in the @INC list of locations.

    Smile,
    Steve

      That's not how it should be working.

      If you have a newer version of a module in a directory that you add with use lib, that should be the one loaded, without need of a version number (so long as that's the last change you make to @INC).

      You should be able to do:

      $ perl -Mautodie -E 'say $autodie::VERSION' 2.23 $ perl -I/usr/foss/packages/foss-perllib -Mautodie -E 'say $autodie::V +ERSION' 2.29


      The way forward always starts with a minimal test.

      As I mentioned in my previous post, I think it would be better to have separate installations of Perl, each with the required set modules of the required versions, with a development installation that is kept up to date. When a new application moves to production, make a new installation of Perl for it and install the modules it needs. this way, each application can have the version of Perl and whatever modules it needs, without worrying about the needs of other applications.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-19 19:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found