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 'foo'
use feature 'switch' tells the compiler to enable the Perl 6 given/when construct from here to the end of the enclosing BLOCK.
use feature 'switch'
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.
use feature '~~'
~~
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.
use feature 'say'
say
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.
use feature 'err'
err
err is a low-precedence variant of the // operator: see perlop for details.
//
perlop
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).
use feature ":5.10"
use feature qw(switch ~~ say err)
To install Env, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Env
CPAN shell
perl -MCPAN -e shell install Env
For more information on module installation, please visit the detailed CPAN module installation guide.