feature
use feature ":5.10"; # this is a "feature bundle"
use feature qw(say state switch unicode_strings);
{
no feature qw(say);
...;
}Perl future-proofs itself by introducing new keywords and
features through the feature pragma.
This pragma enables or disables features in the lexical scope. Specify the
ones you want to turn on or off either by a version tag or the feature
name.
sayEnables the
saykeyword, which is likeprintbut with a free newline.stateEnables
state, which allows persistent subroutine variables.switchEnables Perl’s super-charged switch structure, called
given–when.unicode_stringsThis feature isn’t a keyword. Instead, it causes all string operations within the lexical scope to use Unicode semantics. This also applies to regexes compiled within the scope, even if they should eventually be executed outside of it. See “The Unicode Bug” in perlunicode. This feature is the only one not in the
:v5.10bundle, although it is in the:v5.12and later bundles.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access