in reply to Exposing minimum required perl version ('use x.y.z') to Perl code during runtime?

I'm afraid that is a problem that cannot be reliably solved.

What would you do if one of the modules somewhere in the dependency chain also asks for a (different) minimum version of Perl? Which version will win?

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics
  • Comment on Re: Exposing minimum required perl version ('use x.y.z') to Perl code during runtime?

Replies are listed 'Best First'.
Re^2: Exposing minimum required perl version ('use x.y.z') to Perl code during runtime?
by sedusedan (Pilgrim) on Apr 02, 2014 at 08:44 UTC
    Well, feature.pm could just store the last request. That would be good enough for most cases.

      Well, feature.pm could just store the last request. That would be good enough for most cases.

      Or the user could simply tell your module what he wants :)

      on the one hand, there is no performance benefit between s///r and and the older syntax

      on the other hand catering to multiple perl versions seems like busywork

      on the other hand ...

      perlver - The Perl Minimum Version Analyzer / Perl::MinimumVersion

      ha ha :)

        OK, as usual I'm not expressing myself clearly :) Let's say Data::Sah is just an example. So the performance of s///r, or which version of Perl is most widespread, or which version of Perl to target to to be safe, or Perl::MinimumVersion, all that is red herring.

        What I'm really trying to point out is whether Perl should expose the user's intent of 'use VERSION' to Perl code. And I'm arguing that it should. We can already get version information when user says 'use MODULE VERSION', so why not the case with 'use VERSION'? Aside from my Data::Sah example, I can think of a couple more use-cases where finding out VERSION in 'use VERSION' can be useful:

        1) code analysis -- checking whether user's statement of 'use VERSION' is justified. Here we can use Perl::MinimumVersion to compare what user says she needs and what Perl features she actually uses.

        2) policy enforcement -- we are running some later version of Perl on some servers (say 5.18) but are also running earlier versions (say 5.14), we want to make sure that all code runs under the minimum version and no code says 'use 5.016' or 'use 5.018'. This is of course can also be done using testing/CI, but if Perl can give version information in 'use VERSION', we can also fail on 5.18 test machines.