
feature - Perl pragma to enable new syntactic features

use feature qw(switch say);
given ($foo) {
when (1) { say "\$foo == 1" }
when ([2,3]) { say "\$foo == 2 || \$foo == 3" }
when (/^a[bc]d$/) { say "\$foo eq 'abd' || \$foo eq 'acd'" }
when ($_ > 100) { say "\$foo > 100" }
default { say "None of the above" }
}

It is usually impossible to add new syntax to Perl without breaking some existing programs. This pragma provides a way to minimize that risk. New syntactic constructs can be enabled by use feature 'foo', and will be parsed only when the appropriate feature pragma is in scope.
use feature 'switch' tells the compiler to enable the Perl 6 given/when construct from here to the end of the enclosing BLOCK.
See "Switch statements" in perlsyn for details.
use feature '~~' tells the compiler to enable the Perl 6 smart match ~~ operator from here to the end of the enclosing BLOCK.
See "Smart Matching in Detail" in perlsyn for details.
use feature 'say' tells the compiler to enable the Perl 6 say function from here to the end of the enclosing BLOCK.
See "say" in perlfunc for details.
use feature 'err' tells the compiler to enable the err operator from here to the end of the enclosing BLOCK.
err is a low-precedence variant of the // operator: see perlop for details.
The 'dor' feature is an alias for the 'err' feature.
use feature 'state' tells the compiler to enable state variables from here to the end of the enclosing BLOCK.

It's possible to load a whole slew of features in one go, using a feature bundle. The name of a feature bundle is prefixed with a colon, to distinguish it from an actual feature. At present, the only feature bundle is use feature ":5.10", which is equivalent to use feature qw(switch ~~ say err state).