1nickt has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

In a module I need to specify a minimum version of Perl.

I use:

use v5.10;

and Perl::Critic biffs on ValuesAndExpressions::ProhibitVersionStrings with the rather hilarious error message:

Version string used at line 5, column 1. ValuesAndExpressions::ProhibitVersionStrings (Severity: 3) Whenever you `use' or `require' a module, you can specify a minimu +m version requirement. To ensure compatibility with older Perls, thi +s version number should be expressed as a floating-point number. Do +not use v-strings or three-part numbers. The Perl convention for expre +ssing version numbers as floats is: version + (patch level / 1000). use Foo v1.2 qw(foo bar); # not ok use Foo 1.2.03 qw(foo bar); # not ok use Foo 1.00203 qw(foo bar); # ok

Hilarious because I am trying to tell the machine to NOT use an old version of Perl, LOL.

So I use:

use 5.10;

and Perl biffs with:

Perl v5.100.0 required (did you mean v5.10.0?)--this is only v5.16.0, +stopped at /path/to/module.pm line 5.

So I follow Perl's advice and do:

use 5.10.0;

... and P::C biffs again.

Anything to do other than disable the P::C rule?

Replies are listed 'Best First'.
Re: use 5.10 and Perl::Critic
by Anonymous Monk on Jun 25, 2015 at 19:32 UTC

    The correct backwards-compatible way to say that is use 5.010;.

    I find the best way to quiet a Perl::Critic rule is to reduce its severity below the default level. See the module's doc on how to write a perlcriticrc file.

      Thanks, perfect.

      I do use .perlcriticrc a lot, and don't mind suppressing what I feel are superfluous failures (e.g. not having every single pod section!), but I try to comply where I can :)

Re: use 5.10 and Perl::Critic
by Anonymous Monk on Jun 25, 2015 at 19:42 UTC

    use:

    Specifying VERSION as a literal of the form v5.6.1 should generally be avoided, because it leads to misleading error messages under earlier versions of Perl (that is, prior to 5.6.0) that do not support this syntax. The equivalent numeric version should be used instead.

    use v5.6.1; # compile time version check use 5.6.1; # ditto use 5.006_001; # ditto; preferred for backwards compatibility