Perl: which is included in the use of 5. ##. #?

I saw several posts in which state use 5.12.0; Perl includes by default certain functions / pragmas (e.g. use strict; ). Another example is in UTF-8 and perl , which states that use 5.14.0; there is

optimal for UTF-8 unicode string function.

I seem to recall an accessible use declaration, which provides certain default values ​​(e.g. use strict; use warnings; use diagnostics; ), but cannot remember the specifics. How to find out what is included in this statement use 5.##.#; ? For example, that provides use 5.22.0; default? use strict; ? Anything else? Thanks.

+8
perl use
source share
3 answers

This is described in the perldoc feature :

You can combine several functions together using a set of functions. The name of the function set is a colon prefix to distinguish it from the actual function.

 use feature ":5.10"; 

The following feature packages are available:

 bundle features included --------- ----------------- :default array_base :5.10 say state switch array_base :5.12 say state switch unicode_strings array_base :5.14 say state switch unicode_strings array_base :5.16 say state switch unicode_strings unicode_eval evalbytes current_sub fc :5.18 say state switch unicode_strings unicode_eval evalbytes current_sub fc :5.20 say state switch unicode_strings unicode_eval evalbytes current_sub fc :5.22 say state switch unicode_strings unicode_eval evalbytes current_sub fc 

Where

 use v5.10.0; 

will make implicit

 no feature ':all'; use feature ':5.10'; 

etc.

The automatic inclusion of strictures is documented in perldoc -f use :

if the specified version of Perl is greater than or equal to 5.12.0, the restrictions are lexical, as with use strict .

+10
source share

use 5.12.0; makes use feature ':5.12'; so you get

  • they say
  • state
  • Switch
  • unicode_strings
  • array_base

Function packages are described in the feature.pm documentation.

+2
source share

For improvements not covered by feature , you can use Syntax :: Construct .

+2
source share

All Articles