{
    "mode": "perldoc",
    "parameter": "feature",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/feature/json",
    "generated": "2026-07-05T13:12:38Z",
    "synopsis": "use feature qw(fc say);\n# Without the \"use feature\" above, this code would not be able to find\n# the built-ins \"say\" or \"fc\":\nsay \"The case-folded version of $x is: \" . fc $x;\n# set features to match the :5.10 bundle, which may turn off or on\n# multiple features (see below)\nuse feature ':5.10';\n# implicitly loads :5.10 feature bundle\nuse v5.10;",
    "sections": {
        "NAME": {
            "content": "feature - Perl pragma to enable new features\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use feature qw(fc say);\n\n# Without the \"use feature\" above, this code would not be able to find\n# the built-ins \"say\" or \"fc\":\nsay \"The case-folded version of $x is: \" . fc $x;\n\n\n# set features to match the :5.10 bundle, which may turn off or on\n# multiple features (see below)\nuse feature ':5.10';\n\n\n# implicitly loads :5.10 feature bundle\nuse v5.10;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "It is usually impossible to add new syntax to Perl without breaking some existing programs. This\npragma provides a way to minimize that risk. New syntactic constructs, or new semantic meanings\nto older constructs, can be enabled by \"use feature 'foo'\", and will be parsed only when the\nappropriate feature pragma is in scope. (Nevertheless, the \"CORE::\" prefix provides access to\nall Perl keywords, regardless of this pragma.)\n",
            "subsections": [
                {
                    "name": "Lexical effect",
                    "content": "Like other pragmas (\"use strict\", for example), features have a lexical effect. \"use feature"
                },
                {
                    "name": "qw",
                    "content": "block.\n\n{\nuse feature 'say';\nsay \"say is available here\";\n}\nprint \"But not here.\\n\";\n\n\"no feature\"\nFeatures can also be turned off by using \"no feature \"foo\"\". This too has lexical effect.\n\nuse feature 'say';\nsay \"say is available here\";\n{\nno feature 'say';\nprint \"But not here.\\n\";\n}\nsay \"Yet it is here.\";\n\n\"no feature\" with no features specified will reset to the default group. To disable *all*\nfeatures (an unusual request!) use \"no feature ':all'\".\n"
                }
            ]
        },
        "AVAILABLE FEATURES": {
            "content": "",
            "subsections": [
                {
                    "name": "The 'say' feature",
                    "content": "\"use feature 'say'\" tells the compiler to enable the Raku-inspired \"say\" function.\n\nSee \"say\" in perlfunc for details.\n\nThis feature is available starting with Perl 5.10.\n"
                },
                {
                    "name": "The 'state' feature",
                    "content": "\"use feature 'state'\" tells the compiler to enable \"state\" variables.\n\nSee \"Persistent Private Variables\" in perlsub for details.\n\nThis feature is available starting with Perl 5.10.\n"
                },
                {
                    "name": "The 'switch' feature",
                    "content": "WARNING: This feature is still experimental and the implementation may change or be removed in\nfuture versions of Perl. For this reason, Perl will warn when you use the feature, unless you\nhave explicitly disabled the warning:\n\nno warnings \"experimental::smartmatch\";\n\n\"use feature 'switch'\" tells the compiler to enable the Raku given/when construct.\n\nSee \"Switch Statements\" in perlsyn for details.\n\nThis feature is available starting with Perl 5.10.\n"
                },
                {
                    "name": "The 'unicodestrings' feature",
                    "content": "\"use feature 'unicodestrings'\" tells the compiler to use Unicode rules in all string operations\nexecuted within its scope (unless they are also within the scope of either \"use locale\" or \"use\nbytes\"). The same applies to all regular expressions compiled within the scope, even if executed\noutside it. It does not change the internal representation of strings, but only how they are\ninterpreted.\n\n\"no feature 'unicodestrings'\" tells the compiler to use the traditional Perl rules wherein the\nnative character set rules is used unless it is clear to Perl that Unicode is desired. This can\nlead to some surprises when the behavior suddenly changes. (See \"The \"Unicode Bug\"\" in\nperlunicode for details.) For this reason, if you are potentially using Unicode in your program,\nthe \"use feature 'unicodestrings'\" subpragma is strongly recommended.\n\nThis feature is available starting with Perl 5.12; was almost fully implemented in Perl 5.14;\nand extended in Perl 5.16 to cover \"quotemeta\"; was extended further in Perl 5.26 to cover the\nrange operator; and was extended again in Perl 5.28 to cover special-cased whitespace splitting.\n"
                },
                {
                    "name": "The 'unicodeeval' and 'evalbytes' features",
                    "content": "Together, these two features are intended to replace the legacy string \"eval\" function, which\nbehaves problematically in some instances. They are available starting with Perl 5.16, and are\nenabled by default by a \"use 5.16\" or higher declaration.\n\n\"unicodeeval\" changes the behavior of plain string \"eval\" to work more consistently, especially\nin the Unicode world. Certain (mis)behaviors couldn't be changed without breaking some things\nthat had come to rely on them, so the feature can be enabled and disabled. Details are at \"Under\nthe \"unicodeeval\" feature\" in perlfunc.\n\n\"evalbytes\" is like string \"eval\", but operating on a byte stream that is not UTF-8 encoded.\nDetails are at \"evalbytes EXPR\" in perlfunc. Without a \"use feature 'evalbytes'\" nor a\n\"use v5.16\" (or higher) declaration in the current scope, you can still access it by instead\nwriting \"CORE::evalbytes\".\n"
                },
                {
                    "name": "The 'currentsub' feature",
                    "content": "This provides the \"SUB\" token that returns a reference to the current subroutine or \"undef\"\noutside of a subroutine.\n\nThis feature is available starting with Perl 5.16.\n"
                },
                {
                    "name": "The 'arraybase' feature",
                    "content": "This feature supported the legacy $[ variable. See \"$[\" in perlvar. It was on by default but\ndisabled under \"use v5.16\" (see \"IMPLICIT LOADING\", below) and unavailable since perl 5.30.\n\nThis feature is available under this name starting with Perl 5.16. In previous versions, it was\nsimply on all the time, and this pragma knew nothing about it.\n"
                },
                {
                    "name": "The 'fc' feature",
                    "content": "\"use feature 'fc'\" tells the compiler to enable the \"fc\" function, which implements Unicode\ncasefolding.\n\nSee \"fc\" in perlfunc for details.\n\nThis feature is available from Perl 5.16 onwards.\n"
                },
                {
                    "name": "The 'lexicalsubs' feature",
                    "content": "In Perl versions prior to 5.26, this feature enabled declaration of subroutines via \"my sub\nfoo\", \"state sub foo\" and \"our sub foo\" syntax. See \"Lexical Subroutines\" in perlsub for\ndetails.\n\nThis feature is available from Perl 5.18 onwards. From Perl 5.18 to 5.24, it was classed as\nexperimental, and Perl emitted a warning for its usage, except when explicitly disabled:\n\nno warnings \"experimental::lexicalsubs\";\n\nAs of Perl 5.26, use of this feature no longer triggers a warning, though the\n\"experimental::lexicalsubs\" warning category still exists (for compatibility with code that\ndisables it). In addition, this syntax is not only no longer experimental, but it is enabled for\nall Perl code, regardless of what feature declarations are in scope.\n"
                },
                {
                    "name": "The 'postderef' and 'postderefqq' features",
                    "content": "The 'postderefqq' feature extends the applicability of postfix dereference syntax so that\npostfix array and scalar dereference are available in double-quotish interpolations. For\nexample, it makes the following two statements equivalent:\n\nmy $s = \"[@{ $h->{a} }]\";\nmy $s = \"[$h->{a}->@*]\";\n\nThis feature is available from Perl 5.20 onwards. In Perl 5.20 and 5.22, it was classed as\nexperimental, and Perl emitted a warning for its usage, except when explicitly disabled:\n\nno warnings \"experimental::postderef\";\n\nAs of Perl 5.24, use of this feature no longer triggers a warning, though the\n\"experimental::postderef\" warning category still exists (for compatibility with code that\ndisables it).\n\nThe 'postderef' feature was used in Perl 5.20 and Perl 5.22 to enable postfix dereference syntax\noutside double-quotish interpolations. In those versions, using it triggered the\n\"experimental::postderef\" warning in the same way as the 'postderefqq' feature did. As of Perl\n5.24, this syntax is not only no longer experimental, but it is enabled for all Perl code,\nregardless of what feature declarations are in scope.\n"
                },
                {
                    "name": "The 'signatures' feature",
                    "content": "WARNING: This feature is still experimental and the implementation may change or be removed in\nfuture versions of Perl. For this reason, Perl will warn when you use the feature, unless you\nhave explicitly disabled the warning:\n\nno warnings \"experimental::signatures\";\n\nThis enables unpacking of subroutine arguments into lexical variables by syntax such as\n\nsub foo ($left, $right) {\nreturn $left + $right;\n}\n\nSee \"Signatures\" in perlsub for details.\n\nThis feature is available from Perl 5.20 onwards.\n"
                },
                {
                    "name": "The 'refaliasing' feature",
                    "content": "WARNING: This feature is still experimental and the implementation may change or be removed in\nfuture versions of Perl. For this reason, Perl will warn when you use the feature, unless you\nhave explicitly disabled the warning:\n\nno warnings \"experimental::refaliasing\";\n\nThis enables aliasing via assignment to references:\n\n\\$a = \\$b; # $a and $b now point to the same scalar\n\\@a = \\@b; #                     to the same array\n\\%a = \\%b;\n\\&a = \\&b;\nforeach \\%hash (@arrayofhashrefs) {\n...\n}\n\nSee \"Assigning to References\" in perlref for details.\n\nThis feature is available from Perl 5.22 onwards.\n"
                },
                {
                    "name": "The 'bitwise' feature",
                    "content": "This makes the four standard bitwise operators (\"& | ^ ~\") treat their operands consistently as\nnumbers, and introduces four new dotted operators (\"&. |. ^. ~.\") that treat their operands\nconsistently as strings. The same applies to the assignment variants (\"&= |= ^= &.= |.= ^.=\").\n\nSee \"Bitwise String Operators\" in perlop for details.\n\nThis feature is available from Perl 5.22 onwards. Starting in Perl 5.28, \"use v5.28\" will enable\nthe feature. Before 5.28, it was still experimental and would emit a warning in the\n\"experimental::bitwise\" category.\n"
                },
                {
                    "name": "The 'declaredrefs' feature",
                    "content": "WARNING: This feature is still experimental and the implementation may change or be removed in\nfuture versions of Perl. For this reason, Perl will warn when you use the feature, unless you\nhave explicitly disabled the warning:\n\nno warnings \"experimental::declaredrefs\";\n\nThis allows a reference to a variable to be declared with \"my\", \"state\", our \"our\", or localized\nwith \"local\". It is intended mainly for use in conjunction with the \"refaliasing\" feature. See\n\"Declaring a Reference to a Variable\" in perlref for examples.\n\nThis feature is available from Perl 5.26 onwards.\n"
                },
                {
                    "name": "The 'isa' feature",
                    "content": "WARNING: This feature is still experimental and the implementation may change or be removed in\nfuture versions of Perl. For this reason, Perl will warn when you use the feature, unless you\nhave explicitly disabled the warning:\n\nno warnings \"experimental::isa\";\n\nThis allows the use of the \"isa\" infix operator, which tests whether the scalar given by the\nleft operand is an object of the class given by the right operand. See \"Class Instance Operator\"\nin perlop for more details.\n\nThis feature is available from Perl 5.32 onwards.\n"
                },
                {
                    "name": "The 'indirect' feature",
                    "content": "This feature allows the use of indirect object syntax for method calls, e.g. \"new Foo 1, 2;\". It\nis enabled by default, but can be turned off to disallow indirect object syntax.\n\nThis feature is available under this name from Perl 5.32 onwards. In previous versions, it was\nsimply on all the time. To disallow (or warn on) indirect object syntax on older Perls, see the\nindirect CPAN module.\n"
                },
                {
                    "name": "The 'multidimensional' feature",
                    "content": "This feature enables multidimensional array emulation, a perl 4 (or earlier) feature that was\nused to emulate multidimensional arrays with hashes. This works by converting code like $foo{$x,\n$y} into $foo{join($;, $x, $y)}. It is enabled by default, but can be turned off to disable\nmultidimensional array emulation.\n\nWhen this feature is disabled the syntax that is normally replaced will report a compilation\nerror.\n\nThis feature is available under this name from Perl 5.34 onwards. In previous versions, it was\nsimply on all the time.\n\nYou can use the multidimensional module on CPAN to disable multidimensional array emulation for\nolder versions of Perl.\n"
                },
                {
                    "name": "The 'barewordfilehandles' feature.",
                    "content": "This feature enables bareword filehandles for builtin functions operations, a generally\ndiscouraged practice. It is enabled by default, but can be turned off to disable bareword\nfilehandles, except for the exceptions listed below.\n\nThe perl built-in filehandles \"STDIN\", \"STDOUT\", \"STDERR\", \"DATA\", \"ARGV\", \"ARGVOUT\" and the\nspecial \"\" are always enabled.\n\nThis feature is enabled under this name from Perl 5.34 onwards. In previous versions it was\nsimply on all the time.\n\nYou can use the bareword::filehandles module on CPAN to disable bareword filehandles for older\nversions of perl.\n"
                },
                {
                    "name": "The 'try' feature.",
                    "content": "WARNING: This feature is still experimental and the implementation may change or be removed in\nfuture versions of Perl. For this reason, Perl will warn when you use the feature, unless you\nhave explicitly disabled the warning:\n\nno warnings \"experimental::try\";\n\nThis feature enables the \"try\" and \"catch\" syntax, which allows exception handling, where\nexceptions thrown from the body of the block introduced with \"try\" are caught by executing the\nbody of the \"catch\" block.\n\nFor more information, see \"Try Catch Exception Handling\" in perlsyn.\n"
                }
            ]
        },
        "FEATURE BUNDLES": {
            "content": "It's possible to load multiple features together, using a *feature bundle*. The name of a\nfeature bundle is prefixed with a colon, to distinguish it from an actual feature.\n\nuse feature \":5.10\";\n\nThe following feature bundles are available:\n\nbundle    features included\n--------- -----------------\n:default  indirect multidimensional\nbarewordfilehandles\n\n:5.10     barewordfilehandles indirect\nmultidimensional say state switch\n\n:5.12     barewordfilehandles indirect\nmultidimensional say state switch\nunicodestrings\n\n:5.14     barewordfilehandles indirect\nmultidimensional say state switch\nunicodestrings\n\n:5.16     barewordfilehandles currentsub evalbytes\nfc indirect multidimensional say state\nswitch unicodeeval unicodestrings\n\n:5.18     barewordfilehandles currentsub evalbytes\nfc indirect multidimensional say state\nswitch unicodeeval unicodestrings\n\n:5.20     barewordfilehandles currentsub evalbytes\nfc indirect multidimensional say state\nswitch unicodeeval unicodestrings\n\n:5.22     barewordfilehandles currentsub evalbytes\nfc indirect multidimensional say state\nswitch unicodeeval unicodestrings\n\n:5.24     barewordfilehandles currentsub evalbytes\nfc indirect multidimensional postderefqq\nsay state switch unicodeeval\nunicodestrings\n\n:5.26     barewordfilehandles currentsub evalbytes\nfc indirect multidimensional postderefqq\nsay state switch unicodeeval\nunicodestrings\n\n:5.28     barewordfilehandles bitwise currentsub\nevalbytes fc indirect multidimensional\npostderefqq say state switch unicodeeval\nunicodestrings\n\n:5.30     barewordfilehandles bitwise currentsub\nevalbytes fc indirect multidimensional\npostderefqq say state switch unicodeeval\nunicodestrings\n\n:5.32     barewordfilehandles bitwise currentsub\nevalbytes fc indirect multidimensional\npostderefqq say state switch unicodeeval\nunicodestrings\n\n:5.34     barewordfilehandles bitwise currentsub\nevalbytes fc indirect multidimensional\npostderefqq say state switch unicodeeval\nunicodestrings\n\nThe \":default\" bundle represents the feature set that is enabled before any \"use feature\" or \"no\nfeature\" declaration.\n\nSpecifying sub-versions such as the 0 in 5.14.0 in feature bundles has no effect. Feature\nbundles are guaranteed to be the same for all sub-versions.\n\nuse feature \":5.14.0\";    # same as \":5.14\"\nuse feature \":5.14.1\";    # same as \":5.14\"\n",
            "subsections": []
        },
        "IMPLICIT LOADING": {
            "content": "Instead of loading feature bundles by name, it is easier to let Perl do implicit loading of a\nfeature bundle for you.\n\nThere are two ways to load the \"feature\" pragma implicitly:\n\n*   By using the \"-E\" switch on the Perl command-line instead of \"-e\". That will enable the\nfeature bundle for that version of Perl in the main compilation unit (that is, the one-liner\nthat follows \"-E\").\n\n*   By explicitly requiring a minimum Perl version number for your program, with the \"use\nVERSION\" construct. That is,\n\nuse v5.10.0;\n\nwill do an implicit\n\nno feature ':all';\nuse feature ':5.10';\n\nand so on. Note how the trailing sub-version is automatically stripped from the version.\n\nBut to avoid portability warnings (see \"use\" in perlfunc), you may prefer:\n\nuse 5.010;\n\nwith the same effect.\n\nIf the required version is older than Perl 5.10, the \":default\" feature bundle is\nautomatically loaded instead.\n\nUnlike \"use feature \":5.12\"\", saying \"use v5.12\" (or any higher version) also does the\nequivalent of \"use strict\"; see \"use\" in perlfunc for details.\n",
            "subsections": []
        }
    },
    "summary": "feature - Perl pragma to enable new features",
    "flags": [],
    "examples": [],
    "see_also": []
}