Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl: what's included in use 5.##.#?

Tags:

perl

I've seen several posts that state use 5.12.0; in Perl enables certain features/pragmas by default (e.g., use strict;). Another example is in UTF-8 and perl where it is stated that use 5.14.0; is

optimal for Unicode string feature UTF-8 handling.

I seem to recall an available use declaration that provides certain defaults (e.g., use strict; use warnings; use diagnostics;), but can't remember the specifics. How does one find out what is included in a given use 5.##.#; statement? For example, what does use 5.22.0; provide by default? use strict;?

like image 856
secJ Avatar asked Jul 06 '15 23:07

secJ


3 Answers

This is documented in perldoc feature:

It's possible to load multiple features together, using a feature bundle. The name of a feature bundle is prefixed with a colon, to distinguish it from an actual feature.

use feature ":5.10";

The following feature bundles 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 do an implicit

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

and so on.

Automatic enabling of strictures is documented in perldoc -f use:

if the specified Perl version is greater than or equal to 5.12.0, strictures are enabled lexically as with use strict.

like image 105
ThisSuitIsBlackNot Avatar answered Sep 23 '22 09:09

ThisSuitIsBlackNot


use 5.12.0; does use feature ':5.12';, so you get

  • say
  • state
  • switch
  • unicode_strings
  • array_base

The feature bundles are documented in feature.pm's documentation.

like image 37
ikegami Avatar answered Sep 23 '22 09:09

ikegami


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

like image 41
choroba Avatar answered Sep 24 '22 09:09

choroba