What's the modern way of declaring which version of Perl to use?

后端 未结 3 558
猫巷女王i
猫巷女王i 2021-02-01 07:08

When it come to saying what version of Perl we need for our scripts, we\'ve got options, oh, brother, we\'ve got options:

use 5.010;
use 5.010_001;
use 5.10.0;
u         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-02-01 07:37

    There are really only two options: decimal numbers and v-strings. Which form to use depends in part on which versions of Perl you want to "support" with a meaningful error message instead of a syntax error. (The v-string syntax was added in Perl 5.6.) The accepted best practice -- which is what perlcritic enforces -- is to use decimal notation. You should specify the minimum version of Perl that's required for your script to behave properly. Normally that means declaring a dependency on language features added in a major release, such as using the say function added in 5.10. You should include the patch level if it's important for your script to behave properly. For example, some of my code specifies use 5.008001 because it depends on the fix for a bug that 5.8.0 had which was fixed in 5.8.1.

提交回复
热议问题