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

Perl doesn't keep track of that - it checks the version number supplied against the current version of Perl and dies if the current Perl is too old. If it doesn't die though, it doesn't save the checked version number anywhere. (The file that does this is pp_ctl.c.)

A good default value would be 5.8.1.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
  • Comment on Re^3: Exposing minimum required perl version ('use x.y.z') to Perl code during runtime?
  • Download Code

Replies are listed 'Best First'.
Re^4: Exposing minimum required perl version ('use x.y.z') to Perl code during runtime?
by sedusedan (Pilgrim) on Apr 01, 2014 at 12:33 UTC

    Yeah, I suspect so. Would be nice (for me) if Perl did.

    As for 'good default value', I was referring to "the highest Perl version I can use in the user's environment", so picking a globally safe value like 5.8.x is not good enough. Also, I refuse to go lower than 5.10.1 :)

      Yes, I know what you meant by a good default value. My point is that as Data::Sah allows the user to generate strings of Perl code, it's reasonable user behaviour to be able to expect to output those strings of code to files, and possibly evaluate those files under a different version of Perl.

      So the best default would be to output code which will run on the widest possible range of Perl versions that you're willing to support.

      (I do something similar with Type::Tiny which generates code that runs successfully on Perl 5.6.1 through to the latest blead.)

      use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
      5.8.8 is still common, as many still use RHEL5.