{
    "mode": "man",
    "parameter": "PERLOP",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/PERLOP/1/json",
    "generated": "2026-10-09T12:46:15Z",
    "sections": {
        "NAME": {
            "content": "perlop - Perl operators and precedence\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "In Perl, the operator determines what operation is performed, independent of the type of the\noperands.  For example \"$x + $y\" is always a numeric addition, and if $x or $y do not contain\nnumbers, an attempt is made to convert them to numbers first.\n\nThis is in contrast to many other dynamic languages, where the operation is determined by the\ntype of the first argument.  It also means that Perl has two versions of some operators, one\nfor numeric and one for string comparison.  For example \"$x == $y\" compares two numbers for\nequality, and \"$x eq $y\" compares two strings.\n\nThere are a few exceptions though: \"x\" can be either string repetition or list repetition,\ndepending on the type of the left operand, and \"&\", \"|\", \"^\" and \"~\" can be either string or\nnumeric bit operations.\n",
            "subsections": [
                {
                    "name": "Operator Precedence and Associativity",
                    "content": "Operator precedence and associativity work in Perl more or less like they do in mathematics.\n\nOperator precedence means some operators group more tightly than others.  For example, in \"2\n+ 4 * 5\", the multiplication has higher precedence, so \"4 * 5\" is grouped together as the\nright-hand operand of the addition, rather than \"2 + 4\" being grouped together as the left-\nhand operand of the multiplication. It is as if the expression were written \"2 + (4 * 5)\",\nnot \"(2 + 4) * 5\". So the expression yields \"2 + 20 == 22\", rather than \"6 * 5 == 30\".\n\nOperator associativity defines what happens if a sequence of the same operators is used one\nafter another: usually that they will be grouped at the left or the right. For example, in \"9\n- 3 - 2\", subtraction is left associative, so \"9 - 3\" is grouped together as the left-hand\noperand of the second subtraction, rather than \"3 - 2\" being grouped together as the right-\nhand operand of the first subtraction. It is as if the expression were written \"(9 - 3) - 2\",\nnot \"9 - (3 - 2)\". So the expression yields \"6 - 2 == 4\", rather than \"9 - 1 == 8\".\n\nFor simple operators that evaluate all their operands and then combine the values in some\nway, precedence and associativity (and parentheses) imply some ordering requirements on those\ncombining operations. For example, in 2 + 4 * 5, the grouping implied by precedence means\nthat the multiplication of 4 and 5 must be performed before the addition of 2 and 20, simply\nbecause the result of that multiplication is required as one of the operands of the addition.\nBut the order of operations is not fully determined by this: in \"2 * 2 + 4 * 5\" both\nmultiplications must be performed before the addition, but the grouping does not say anything\nabout the order in which the two multiplications are performed. In fact Perl has a general\nrule that the operands of an operator are evaluated in left-to-right order. A few operators\nsuch as \"&&=\" have special evaluation rules that can result in an operand not being evaluated\nat all; in general, the top-level operator in an expression has control of operand\nevaluation.\n\nSome comparison operators, as their associativity, chain with some operators of the same\nprecedence (but never with operators of different precedence).  This chaining means that each\ncomparison is performed on the two arguments surrounding it, with each interior argument\ntaking part in two comparisons, and the comparison results are implicitly ANDed.  Thus\n\"$x < $y <= $z\" behaves exactly like \"$x < $y && $y <= $z\", assuming that \"$y\" is as simple a\nscalar as it looks.  The ANDing short-circuits just like \"&&\" does, stopping the sequence of\ncomparisons as soon as one yields false.\n\nIn a chained comparison, each argument expression is evaluated at most once, even if it takes\npart in two comparisons, but the result of the evaluation is fetched for each comparison.\n(It is not evaluated at all if the short-circuiting means that it's not required for any\ncomparisons.)  This matters if the computation of an interior argument is expensive or non-\ndeterministic.  For example,\n\nif($x < expensivesub() <= $z) { ...\n\nis not entirely like\n\nif($x < expensivesub() && expensivesub() <= $z) { ...\n\nbut instead closer to\n\nmy $tmp = expensivesub();\nif($x < $tmp && $tmp <= $z) { ...\n\nin that the subroutine is only called once.  However, it's not exactly like this latter code\neither, because the chained comparison doesn't actually involve any temporary variable (named\nor otherwise): there is no assignment.  This doesn't make much difference where the\nexpression is a call to an ordinary subroutine, but matters more with an lvalue subroutine,\nor if the argument expression yields some unusual kind of scalar by other means.  For\nexample, if the argument expression yields a tied scalar, then the expression is evaluated to\nproduce that scalar at most once, but the value of that scalar may be fetched up to twice,\nonce for each comparison in which it is actually used.\n\nIn this example, the expression is evaluated only once, and the tied scalar (the result of\nthe expression) is fetched for each comparison that uses it.\n\nif ($x < $tiedscalar < $z) { ...\n\nIn the next example, the expression is evaluated only once, and the tied scalar is fetched\nonce as part of the operation within the expression.  The result of that operation is fetched\nfor each comparison, which normally doesn't matter unless that expression result is also\nmagical due to operator overloading.\n\nif ($x < $tiedscalar + 42 < $z) { ...\n\nSome operators are instead non-associative, meaning that it is a syntax error to use a\nsequence of those operators of the same precedence.  For example, \"$x .. $y .. $z\" is an\nerror.\n\nPerl operators have the following associativity and precedence, listed from highest\nprecedence to lowest.  Operators borrowed from C keep the same precedence relationship with\neach other, even where C's precedence is slightly screwy.  (This makes learning Perl easier\nfor C folks.)  With very few exceptions, these all operate on scalar values only, not array\nvalues.\n\nleft        terms and list operators (leftward)\nleft        ->\nnonassoc    ++ --\nright\nright       ! ~ ~. \\ and unary + and -\nleft        =~ !~\nleft        * / % x\nleft        + - .\nleft        << >>\nnonassoc    named unary operators\nnonassoc    isa\nchained     < > <= >= lt gt le ge\nchain/na    == != eq ne <=> cmp ~~\nleft        & &.\nleft        | |. ^ ^.\nleft        &&\nleft        || //\nnonassoc    ..  ...\nright       ?:\nright       = += -= *= etc. goto last next redo dump\nleft        , =>\nnonassoc    list operators (rightward)\nright       not\nleft        and\nleft        or xor\n\nIn the following sections, these operators are covered in detail, in the same order in which\nthey appear in the table above.\n\nMany operators can be overloaded for objects.  See overload.\n"
                },
                {
                    "name": "Terms and List Operators (Leftward)",
                    "content": "A TERM has the highest precedence in Perl.  They include variables, quote and quote-like\noperators, any expression in parentheses, and any function whose arguments are parenthesized.\nActually, there aren't really functions in this sense, just list operators and unary\noperators behaving as functions because you put parentheses around the arguments.  These are\nall documented in perlfunc.\n\nIf any list operator (print(), etc.) or any unary operator (chdir(), etc.)  is followed by a\nleft parenthesis as the next token, the operator and arguments within parentheses are taken\nto be of highest precedence, just like a normal function call.\n\nIn the absence of parentheses, the precedence of list operators such as \"print\", \"sort\", or\n\"chmod\" is either very high or very low depending on whether you are looking at the left side\nor the right side of the operator.  For example, in\n\n@ary = (1, 3, sort 4, 2);\nprint @ary;         # prints 1324\n\nthe commas on the right of the \"sort\" are evaluated before the \"sort\", but the commas on the\nleft are evaluated after.  In other words, list operators tend to gobble up all arguments\nthat follow, and then act like a simple TERM with regard to the preceding expression.  Be\ncareful with parentheses:\n\n# These evaluate exit before doing the print:\nprint($foo, exit);  # Obviously not what you want.\nprint $foo, exit;   # Nor is this.\n\n# These do the print before evaluating exit:\n(print $foo), exit; # This is what you want.\nprint($foo), exit;  # Or this.\nprint ($foo), exit; # Or even this.\n\nAlso note that\n\nprint ($foo & 255) + 1, \"\\n\";\n\nprobably doesn't do what you expect at first glance.  The parentheses enclose the argument\nlist for \"print\" which is evaluated (printing the result of \"$foo & 255\").  Then one is added\nto the return value of \"print\" (usually 1).  The result is something like this:\n\n1 + 1, \"\\n\";    # Obviously not what you meant.\n\nTo do what you meant properly, you must write:\n\nprint(($foo & 255) + 1, \"\\n\");\n\nSee \"Named Unary Operators\" for more discussion of this.\n\nAlso parsed as terms are the \"do {}\" and \"eval {}\" constructs, as well as subroutine and\nmethod calls, and the anonymous constructors \"[]\" and \"{}\".\n\nSee also \"Quote and Quote-like Operators\" toward the end of this section, as well as \"I/O\nOperators\".\n"
                },
                {
                    "name": "The Arrow Operator",
                    "content": "\"\"->\"\" is an infix dereference operator, just as it is in C and C++.  If the right side is\neither a \"[...]\", \"{...}\", or a \"(...)\" subscript, then the left side must be either a hard\nor symbolic reference to an array, a hash, or a subroutine respectively.  (Or technically\nspeaking, a location capable of holding a hard reference, if it's an array or hash reference\nbeing used for assignment.)  See perlreftut and perlref.\n\nOtherwise, the right side is a method name or a simple scalar variable containing either the\nmethod name or a subroutine reference, and (if it is a method name) the left side must be\neither an object (a blessed reference) or a class name (that is, a package name).  See\nperlobj.\n\nThe dereferencing cases (as opposed to method-calling cases) are somewhat extended by the\n\"postderef\" feature.  For the details of that feature, consult \"Postfix Dereference Syntax\"\nin perlref.\n"
                },
                {
                    "name": "Auto-increment and Auto-decrement",
                    "content": "\"++\" and \"--\" work as in C.  That is, if placed before a variable, they increment or\ndecrement the variable by one before returning the value, and if placed after, increment or\ndecrement after returning the value.\n\n$i = 0;  $j = 0;\nprint $i++;  # prints 0\nprint ++$j;  # prints 1\n\nNote that just as in C, Perl doesn't define when the variable is incremented or decremented.\nYou just know it will be done sometime before or after the value is returned.  This also\nmeans that modifying a variable twice in the same statement will lead to undefined behavior.\nAvoid statements like:\n\n$i = $i ++;\nprint ++ $i + $i ++;\n\nPerl will not guarantee what the result of the above statements is.\n\nThe auto-increment operator has a little extra builtin magic to it.  If you increment a\nvariable that is numeric, or that has ever been used in a numeric context, you get a normal\nincrement.  If, however, the variable has been used in only string contexts since it was set,\nand has a value that is not the empty string and matches the pattern \"/^[a-zA-Z]*[0-9]*\\z/\",\nthe increment is done as a string, preserving each character within its range, with carry:\n\nprint ++($foo = \"99\");      # prints \"100\"\nprint ++($foo = \"a0\");      # prints \"a1\"\nprint ++($foo = \"Az\");      # prints \"Ba\"\nprint ++($foo = \"zz\");      # prints \"aaa\"\n\n\"undef\" is always treated as numeric, and in particular is changed to 0 before incrementing\n(so that a post-increment of an undef value will return 0 rather than \"undef\").\n\nThe auto-decrement operator is not magical.\n"
                },
                {
                    "name": "Exponentiation",
                    "content": "Binary \"\" is the exponentiation operator.  It binds even more tightly than unary minus, so\n\"-24\" is \"-(24)\", not \"(-2)4\".  (This is implemented using C's pow(3) function, which\nactually works on doubles internally.)\n\nNote that certain exponentiation expressions are ill-defined: these include \"00\", \"1Inf\",\nand \"Inf0\".  Do not expect any particular results from these special cases, the results are\nplatform-dependent.\n"
                },
                {
                    "name": "Symbolic Unary Operators",
                    "content": "Unary \"!\" performs logical negation, that is, \"not\".  See also \"not\" for a lower precedence\nversion of this.\n\nUnary \"-\" performs arithmetic negation if the operand is numeric, including any string that\nlooks like a number.  If the operand is an identifier, a string consisting of a minus sign\nconcatenated with the identifier is returned.  Otherwise, if the string starts with a plus or\nminus, a string starting with the opposite sign is returned.  One effect of these rules is\nthat \"-bareword\" is equivalent to the string \"-bareword\".  If, however, the string begins\nwith a non-alphabetic character (excluding \"+\" or \"-\"), Perl will attempt to convert the\nstring to a numeric, and the arithmetic negation is performed.  If the string cannot be\ncleanly converted to a numeric, Perl will give the warning Argument \"the string\" isn't\nnumeric in negation (-) at ....\n\nUnary \"~\" performs bitwise negation, that is, 1's complement.  For example, \"0666 & ~027\" is\n0640.  (See also \"Integer Arithmetic\" and \"Bitwise String Operators\".)  Note that the width\nof the result is platform-dependent: \"~0\" is 32 bits wide on a 32-bit platform, but 64 bits\nwide on a 64-bit platform, so if you are expecting a certain bit width, remember to use the\n\"&\" operator to mask off the excess bits.\n\nStarting in Perl 5.28, it is a fatal error to try to complement a string containing a\ncharacter with an ordinal value above 255.\n\nIf the \"bitwise\" feature is enabled via \"use feature 'bitwise'\" or \"use v5.28\", then unary\n\"~\" always treats its argument as a number, and an alternate form of the operator, \"~.\",\nalways treats its argument as a string.  So \"~0\" and \"~\"0\"\" will both give 232-1 on 32-bit\nplatforms, whereas \"~.0\" and \"~.\"0\"\" will both yield \"\\xff\".  Until Perl 5.28, this feature\nproduced a warning in the \"experimental::bitwise\" category.\n\nUnary \"+\" has no effect whatsoever, even on strings.  It is useful syntactically for\nseparating a function name from a parenthesized expression that would otherwise be\ninterpreted as the complete list of function arguments.  (See examples above under \"Terms and\nList Operators (Leftward)\".)\n\nUnary \"\\\" creates references.  If its operand is a single sigilled thing, it creates a\nreference to that object.  If its operand is a parenthesised list, then it creates references\nto the things mentioned in the list.  Otherwise it puts its operand in list context, and\ncreates a list of references to the scalars in the list provided by the operand.  See\nperlreftut and perlref.  Do not confuse this behavior with the behavior of backslash within a\nstring, although both forms do convey the notion of protecting the next thing from\ninterpolation.\n"
                },
                {
                    "name": "Binding Operators",
                    "content": "Binary \"=~\" binds a scalar expression to a pattern match.  Certain operations search or\nmodify the string $ by default.  This operator makes that kind of operation work on some\nother string.  The right argument is a search pattern, substitution, or transliteration.  The\nleft argument is what is supposed to be searched, substituted, or transliterated instead of\nthe default $.  When used in scalar context, the return value generally indicates the\nsuccess of the operation.  The exceptions are substitution (\"s///\") and transliteration\n(\"y///\") with the \"/r\" (non-destructive) option, which cause the return value to be the\nresult of the substitution.  Behavior in list context depends on the particular operator.\nSee \"Regexp Quote-Like Operators\" for details and perlretut for examples using these\noperators.\n\nIf the right argument is an expression rather than a search pattern, substitution, or\ntransliteration, it is interpreted as a search pattern at run time.  Note that this means\nthat its contents will be interpolated twice, so\n\n'\\\\' =~ q'\\\\';\n\nis not ok, as the regex engine will end up trying to compile the pattern \"\\\", which it will\nconsider a syntax error.\n\nBinary \"!~\" is just like \"=~\" except the return value is negated in the logical sense.\n\nBinary \"!~\" with a non-destructive substitution (\"s///r\") or transliteration (\"y///r\") is a\nsyntax error.\n"
                },
                {
                    "name": "Multiplicative Operators",
                    "content": "Binary \"*\" multiplies two numbers.\n\nBinary \"/\" divides two numbers.\n\nBinary \"%\" is the modulo operator, which computes the division remainder of its first\nargument with respect to its second argument.  Given integer operands $m and $n: If $n is\npositive, then \"$m % $n\" is $m minus the largest multiple of $n less than or equal to $m.  If\n$n is negative, then \"$m % $n\" is $m minus the smallest multiple of $n that is not less than\n$m (that is, the result will be less than or equal to zero).  If the operands $m and $n are\nfloating point values and the absolute value of $n (that is abs($n)) is less than\n\"(UVMAX + 1)\", only the integer portion of $m and $n will be used in the operation (Note:\nhere \"UVMAX\" means the maximum of the unsigned integer type).  If the absolute value of the\nright operand (abs($n)) is greater than or equal to \"(UVMAX + 1)\", \"%\" computes the\nfloating-point remainder $r in the equation \"($r = $m - $i*$n)\" where $i is a certain integer\nthat makes $r have the same sign as the right operand $n (not as the left operand $m like C\nfunction fmod()) and the absolute value less than that of $n.  Note that when \"use integer\"\nis in scope, \"%\" gives you direct access to the modulo operator as implemented by your C\ncompiler.  This operator is not as well defined for negative operands, but it will execute\nfaster.\n\nBinary \"x\" is the repetition operator.  In scalar context, or if the left operand is neither\nenclosed in parentheses nor a \"qw//\" list, it performs a string repetition.  In that case it\nsupplies scalar context to the left operand, and returns a string consisting of the left\noperand string repeated the number of times specified by the right operand.  If the \"x\" is in\nlist context, and the left operand is either enclosed in parentheses or a \"qw//\" list, it\nperforms a list repetition.  In that case it supplies list context to the left operand, and\nreturns a list consisting of the left operand list repeated the number of times specified by\nthe right operand.  If the right operand is zero or negative (raising a warning on negative),\nit returns an empty string or an empty list, depending on the context.\n\nprint '-' x 80;             # print row of dashes\n\nprint \"\\t\" x ($tab/8), ' ' x ($tab%8);      # tab over\n\n@ones = (1) x 80;           # a list of 80 1's\n@ones = (5) x @ones;        # set all elements to 5\n"
                },
                {
                    "name": "Additive Operators",
                    "content": "Binary \"+\" returns the sum of two numbers.\n\nBinary \"-\" returns the difference of two numbers.\n\nBinary \".\" concatenates two strings.\n"
                },
                {
                    "name": "Shift Operators",
                    "content": "Binary \"<<\" returns the value of its left argument shifted left by the number of bits\nspecified by the right argument.  Arguments should be integers.  (See also \"Integer\nArithmetic\".)\n\nBinary \">>\" returns the value of its left argument shifted right by the number of bits\nspecified by the right argument.  Arguments should be integers.  (See also \"Integer\nArithmetic\".)\n\nIf \"use integer\" (see \"Integer Arithmetic\") is in force then signed C integers are used\n(arithmetic shift), otherwise unsigned C integers are used (logical shift), even for negative\nshiftees.  In arithmetic right shift the sign bit is replicated on the left, in logical shift\nzero bits come in from the left.\n\nEither way, the implementation isn't going to generate results larger than the size of the\ninteger type Perl was built with (32 bits or 64 bits).\n\nShifting by negative number of bits means the reverse shift: left shift becomes right shift,\nright shift becomes left shift.  This is unlike in C, where negative shift is undefined.\n\nShifting by more bits than the size of the integers means most of the time zero (all bits\nfall off), except that under \"use integer\" right overshifting a negative shiftee results in\n-1.  This is unlike in C, where shifting by too many bits is undefined.  A common C behavior\nis \"shift by modulo wordbits\", so that for example\n\n1 >> 64 == 1 >> (64 % 64) == 1 >> 0 == 1  # Common C behavior.\n\nbut that is completely accidental.\n\nIf you get tired of being subject to your platform's native integers, the \"use bigint\" pragma\nneatly sidesteps the issue altogether:\n\nprint 20 << 20;  # 20971520\nprint 20 << 40;  # 5120 on 32-bit machines,\n# 21990232555520 on 64-bit machines\nuse bigint;\nprint 20 << 100; # 25353012004564588029934064107520\n"
                },
                {
                    "name": "Named Unary Operators",
                    "content": "The various named unary operators are treated as functions with one argument, with optional\nparentheses.\n\nIf any list operator (print(), etc.) or any unary operator (chdir(), etc.)  is followed by a\nleft parenthesis as the next token, the operator and arguments within parentheses are taken\nto be of highest precedence, just like a normal function call.  For example, because named\nunary operators are higher precedence than \"||\":\n\nchdir $foo    || die;       # (chdir $foo) || die\nchdir($foo)   || die;       # (chdir $foo) || die\nchdir ($foo)  || die;       # (chdir $foo) || die\nchdir +($foo) || die;       # (chdir $foo) || die\n\nbut, because \"*\" is higher precedence than named operators:\n\nchdir $foo * 20;    # chdir ($foo * 20)\nchdir($foo) * 20;   # (chdir $foo) * 20\nchdir ($foo) * 20;  # (chdir $foo) * 20\nchdir +($foo) * 20; # chdir ($foo * 20)\n\nrand 10 * 20;       # rand (10 * 20)\nrand(10) * 20;      # (rand 10) * 20\nrand (10) * 20;     # (rand 10) * 20\nrand +(10) * 20;    # rand (10 * 20)\n\nRegarding precedence, the filetest operators, like \"-f\", \"-M\", etc. are treated like named\nunary operators, but they don't follow this functional parenthesis rule.  That means, for\nexample, that \"-f($file).\".bak\"\" is equivalent to \"-f \"$file.bak\"\".\n\nSee also \"Terms and List Operators (Leftward)\".\n"
                },
                {
                    "name": "Relational Operators",
                    "content": "Perl operators that return true or false generally return values that can be safely used as\nnumbers.  For example, the relational operators in this section and the equality operators in\nthe next one return 1 for true and a special version of the defined empty string, \"\", which\ncounts as a zero but is exempt from warnings about improper numeric conversions, just as\n\"0 but true\" is.\n\nBinary \"<\" returns true if the left argument is numerically less than the right argument.\n\nBinary \">\" returns true if the left argument is numerically greater than the right argument.\n\nBinary \"<=\" returns true if the left argument is numerically less than or equal to the right\nargument.\n\nBinary \">=\" returns true if the left argument is numerically greater than or equal to the\nright argument.\n\nBinary \"lt\" returns true if the left argument is stringwise less than the right argument.\n\nBinary \"gt\" returns true if the left argument is stringwise greater than the right argument.\n\nBinary \"le\" returns true if the left argument is stringwise less than or equal to the right\nargument.\n\nBinary \"ge\" returns true if the left argument is stringwise greater than or equal to the\nright argument.\n\nA sequence of relational operators, such as \"$x < $y <= $z\", performs chained comparisons, in\nthe manner described above in the section \"Operator Precedence and Associativity\".  Beware\nthat they do not chain with equality operators, which have lower precedence.\n"
                },
                {
                    "name": "Equality Operators",
                    "content": "Binary \"==\" returns true if the left argument is numerically equal to the right argument.\n\nBinary \"!=\" returns true if the left argument is numerically not equal to the right argument.\n\nBinary \"eq\" returns true if the left argument is stringwise equal to the right argument.\n\nBinary \"ne\" returns true if the left argument is stringwise not equal to the right argument.\n\nA sequence of the above equality operators, such as \"$x == $y == $z\", performs chained\ncomparisons, in the manner described above in the section \"Operator Precedence and\nAssociativity\".  Beware that they do not chain with relational operators, which have higher\nprecedence.\n\nBinary \"<=>\" returns -1, 0, or 1 depending on whether the left argument is numerically less\nthan, equal to, or greater than the right argument.  If your platform supports \"NaN\"'s (not-\na-numbers) as numeric values, using them with \"<=>\" returns undef.  \"NaN\" is not \"<\", \"==\",\n\">\", \"<=\" or \">=\" anything (even \"NaN\"), so those 5 return false.  \"NaN != NaN\" returns true,\nas does \"NaN !=\" anything else.  If your platform doesn't support \"NaN\"'s then \"NaN\" is just\na string with numeric value 0.\n\n$ perl -le '$x = \"NaN\"; print \"No NaN support here\" if $x == $x'\n$ perl -le '$x = \"NaN\"; print \"NaN support here\" if $x != $x'\n\n(Note that the bigint, bigrat, and bignum pragmas all support \"NaN\".)\n\nBinary \"cmp\" returns -1, 0, or 1 depending on whether the left argument is stringwise less\nthan, equal to, or greater than the right argument.\n\nHere we can see the difference between <=> and cmp,\n\nprint 10 <=> 2 #prints 1\nprint 10 cmp 2 #prints -1\n\n(likewise between gt and >, lt and <, etc.)\n\nBinary \"~~\" does a smartmatch between its arguments.  Smart matching is described in the next\nsection.\n\nThe two-sided ordering operators \"<=>\" and \"cmp\", and the smartmatch operator \"~~\", are non-\nassociative with respect to each other and with respect to the equality operators of the same\nprecedence.\n\n\"lt\", \"le\", \"ge\", \"gt\" and \"cmp\" use the collation (sort) order specified by the current\n\"LCCOLLATE\" locale if a \"use locale\" form that includes collation is in effect.  See\nperllocale.  Do not mix these with Unicode, only use them with legacy 8-bit locale encodings.\nThe standard \"Unicode::Collate\" and \"Unicode::Collate::Locale\" modules offer much more\npowerful solutions to collation issues.\n\nFor case-insensitive comparisons, look at the \"fc\" in perlfunc case-folding function,\navailable in Perl v5.16 or later:\n\nif ( fc($x) eq fc($y) ) { ... }\n"
                },
                {
                    "name": "Class Instance Operator",
                    "content": "Binary \"isa\" evaluates to true when the left argument is an object instance of the class (or\na subclass derived from that class) given by the right argument.  If the left argument is not\ndefined, not a blessed object instance, nor does not derive from the class given by the right\nargument, the operator evaluates as false. The right argument may give the class either as a\nbareword or a scalar expression that yields a string class name:\n\nif( $obj isa Some::Class ) { ... }\n\nif( $obj isa \"Different::Class\" ) { ... }\nif( $obj isa $nameofclass ) { ... }\n\nThis feature is available from Perl 5.31.6 onwards when enabled by \"use feature 'isa'\". This\nfeature is enabled automatically by a \"use v5.36\" (or higher) declaration in the current\nscope.\n"
                },
                {
                    "name": "Smartmatch Operator",
                    "content": "First available in Perl 5.10.1 (the 5.10.0 version behaved differently), binary \"~~\" does a\n\"smartmatch\" between its arguments.  This is mostly used implicitly in the \"when\" construct\ndescribed in perlsyn, although not all \"when\" clauses call the smartmatch operator.  Unique\namong all of Perl's operators, the smartmatch operator can recurse.  The smartmatch operator\nis experimental and its behavior is subject to change.\n\nIt is also unique in that all other Perl operators impose a context (usually string or\nnumeric context) on their operands, autoconverting those operands to those imposed contexts.\nIn contrast, smartmatch infers contexts from the actual types of its operands and uses that\ntype information to select a suitable comparison mechanism.\n\nThe \"~~\" operator compares its operands \"polymorphically\", determining how to compare them\naccording to their actual types (numeric, string, array, hash, etc.).  Like the equality\noperators with which it shares the same precedence, \"~~\" returns 1 for true and \"\" for false.\nIt is often best read aloud as \"in\", \"inside of\", or \"is contained in\", because the left\noperand is often looked for inside the right operand.  That makes the order of the operands\nto the smartmatch operand often opposite that of the regular match operator.  In other words,\nthe \"smaller\" thing is usually placed in the left operand and the larger one in the right.\n\nThe behavior of a smartmatch depends on what type of things its arguments are, as determined\nby the following table.  The first row of the table whose types apply determines the\nsmartmatch behavior.  Because what actually happens is mostly determined by the type of the\nsecond operand, the table is sorted on the right operand instead of on the left.\n\nLeft      Right      Description and pseudocode\n===============================================================\nAny       undef      check whether Any is undefined\nlike: !defined Any\n\nAny       Object     invoke ~~ overloading on Object, or die\n\nRight operand is an ARRAY:\n\nLeft      Right      Description and pseudocode\n===============================================================\nARRAY1    ARRAY2     recurse on paired elements of ARRAY1 and ARRAY2[2]\nlike: (ARRAY1[0] ~~ ARRAY2[0])\n&& (ARRAY1[1] ~~ ARRAY2[1]) && ...\nHASH      ARRAY      any ARRAY elements exist as HASH keys\nlike: grep { exists HASH->{$} } ARRAY\nRegexp    ARRAY      any ARRAY elements pattern match Regexp\nlike: grep { /Regexp/ } ARRAY\nundef     ARRAY      undef in ARRAY\nlike: grep { !defined } ARRAY\nAny       ARRAY      smartmatch each ARRAY element[3]\nlike: grep { Any ~~ $ } ARRAY\n\nRight operand is a HASH:\n\nLeft      Right      Description and pseudocode\n===============================================================\nHASH1     HASH2      all same keys in both HASHes\nlike: keys HASH1 ==\ngrep { exists HASH2->{$} } keys HASH1\nARRAY     HASH       any ARRAY elements exist as HASH keys\nlike: grep { exists HASH->{$} } ARRAY\nRegexp    HASH       any HASH keys pattern match Regexp\nlike: grep { /Regexp/ } keys HASH\nundef     HASH       always false (undef cannot be a key)\nlike: 0 == 1\nAny       HASH       HASH key existence\nlike: exists HASH->{Any}\n\nRight operand is CODE:\n\nLeft      Right      Description and pseudocode\n===============================================================\nARRAY     CODE       sub returns true on all ARRAY elements[1]\nlike: !grep { !CODE->($) } ARRAY\nHASH      CODE       sub returns true on all HASH keys[1]\nlike: !grep { !CODE->($) } keys HASH\nAny       CODE       sub passed Any returns true\nlike: CODE->(Any)\n\nRight operand is a Regexp:\n\nLeft      Right      Description and pseudocode\n===============================================================\nARRAY     Regexp     any ARRAY elements match Regexp\nlike: grep { /Regexp/ } ARRAY\nHASH      Regexp     any HASH keys match Regexp\nlike: grep { /Regexp/ } keys HASH\nAny       Regexp     pattern match\nlike: Any =~ /Regexp/\n\nOther:\n\nLeft      Right      Description and pseudocode\n===============================================================\nObject    Any        invoke ~~ overloading on Object,\nor fall back to...\n\nAny       Num        numeric equality\nlike: Any == Num\nNum       nummy[4]    numeric equality\nlike: Num == nummy\nundef     Any        check whether undefined\nlike: !defined(Any)\nAny       Any        string equality\nlike: Any eq Any\n\nNotes:\n\n1. Empty hashes or arrays match.\n2. That is, each element smartmatches the element of the same index in the other array.[3]\n3. If a circular reference is found, fall back to referential equality.\n4. Either an actual number, or a string that looks like one.\n\nThe smartmatch implicitly dereferences any non-blessed hash or array reference, so the \"HASH\"\nand  \"ARRAY\"  entries  apply  in  those  cases.  For blessed references, the \"Object\" entries\napply.  Smartmatches involving hashes only consider hash keys, never hash values.\n\nThe \"like\" code entry is not always an exact rendition.  For example, the smartmatch operator\nshort-circuits whenever possible, but \"grep\"  does  not.   Also,  \"grep\"  in  scalar  context\nreturns the number of matches, but \"~~\" returns only true or false.\n\nUnlike most operators, the smartmatch operator knows to treat \"undef\" specially:\n\nuse v5.10.1;\n@array = (1, 2, 3, undef, 4, 5);\nsay \"some elements undefined\" if undef ~~ @array;\n\nEach  operand  is  considered in a modified scalar context, the modification being that array\nand hash variables are passed by reference to the  operator,  which  implicitly  dereferences\nthem.  Both elements of each pair are the same:\n\nuse v5.10.1;\n\nmy %hash = (red    => 1, blue   => 2, green  => 3,\norange => 4, yellow => 5, purple => 6,\nblack  => 7, grey   => 8, white  => 9);\n\nmy @array = qw(red blue green);\n\nsay \"some array elements in hash keys\" if  @array ~~  %hash;\nsay \"some array elements in hash keys\" if \\@array ~~ \\%hash;\n\nsay \"red in array\" if \"red\" ~~  @array;\nsay \"red in array\" if \"red\" ~~ \\@array;\n\nsay \"some keys end in e\" if /e$/ ~~  %hash;\nsay \"some keys end in e\" if /e$/ ~~ \\%hash;\n\nTwo  arrays smartmatch if each element in the first array smartmatches (that is, is \"in\") the\ncorresponding element in the second array, recursively.\n\nuse v5.10.1;\nmy @little = qw(red blue green);\nmy @bigger = (\"red\", \"blue\", [ \"orange\", \"green\" ] );\nif (@little ~~ @bigger) {  # true!\nsay \"little is contained in bigger\";\n}\n\nBecause the smartmatch operator recurses on nested arrays, this will still report that  \"red\"\nis in the array.\n\nuse v5.10.1;\nmy @array = qw(red blue green);\nmy $nestedarray = [[[[[[[ @array ]]]]]]];\nsay \"red in array\" if \"red\" ~~ $nestedarray;\n\nIf  two  arrays  smartmatch  each other, then they are deep copies of each others' values, as\nthis example reports:\n\nuse v5.12.0;\nmy @a = (0, 1, 2, [3, [4, 5], 6], 7);\nmy @b = (0, 1, 2, [3, [4, 5], 6], 7);\n\nif (@a ~~ @b && @b ~~ @a) {\nsay \"a and b are deep copies of each other\";\n}\nelsif (@a ~~ @b) {\nsay \"a smartmatches in b\";\n}\nelsif (@b ~~ @a) {\nsay \"b smartmatches in a\";\n}\nelse {\nsay \"a and b don't smartmatch each other at all\";\n}\n\nIf you were to set \"$b[3] = 4\", then instead of reporting that \"a and b are  deep  copies  of\neach  other\",  it  now  reports that \"b smartmatches in a\".  That's because the corresponding\nposition in @a contains an array that (eventually) has a 4 in it.\n\nSmartmatching one hash against another reports whether both contain the same  keys,  no  more\nand  no  less.   This  could  be  used  to see whether two records have the same field names,\nwithout caring what values those fields might have.  For example:\n\nuse v5.10.1;\nsub makedogtag {\nstate $REQUIREDFIELDS = { name=>1, rank=>1, serialnum=>1 };\n\nmy ($class, $initfields) = @;\n\ndie \"Must supply (only) name, rank, and serial number\"\nunless $initfields ~~ $REQUIREDFIELDS;\n\n...\n}\n\nHowever, this only does what you mean  if  $initfields  is  indeed  a  hash  reference.  The\ncondition  \"$initfields  ~~  $REQUIREDFIELDS\"  also  allows  the  strings  \"name\",  \"rank\",\n\"serialnum\" as well as any array reference that contains \"name\" or  \"rank\"  or  \"serialnum\"\nanywhere to pass through.\n\nThe  smartmatch operator is most often used as the implicit operator of a \"when\" clause.  See\nthe section on \"Switch Statements\" in perlsyn.\n\nSmartmatching of Objects\n\nTo avoid relying on an object's underlying representation, if the smartmatch's right  operand\nis  an  object  that  doesn't  overload  \"~~\",  it  raises  the  exception  \"\"Smartmatching a\nnon-overloaded object breaks encapsulation\"\".  That's because one  has  no  business  digging\naround  to see whether something is \"in\" an object.  These are all illegal on objects without\na \"~~\" overload:\n\n%hash ~~ $object\n42 ~~ $object\n\"fred\" ~~ $object\n\nHowever, you can change the way an object is smartmatched by overloading the  \"~~\"  operator.\nThis  is  allowed to extend the usual smartmatch semantics.  For objects that do have an \"~~\"\noverload, see overload.\n\nUsing an object as the left operand is allowed,  although  not  very  useful.   Smartmatching\nrules  take  precedence  over  overloading,  so  even  if  the object in the left operand has\nsmartmatch overloading, this will be ignored.  A left operand that is a non-overloaded object\nfalls back on a string or numeric comparison of whatever the \"ref\"  operator  returns.   That\nmeans that\n\n$object ~~ X\n\ndoes  not  invoke  the  overload  method with \"X\" as an argument.  Instead the above table is\nconsulted as normal, and based on the type of \"X\", overloading may or  may  not  be  invoked.\nFor simple strings or numbers, \"in\" becomes equivalent to this:\n\n$object ~~ $number          ref($object) == $number\n$object ~~ $string          ref($object) eq $string\n\nFor example, this reports that the handle smells IOish (but please don't really do this!):\n\nuse IO::Handle;\nmy $fh = IO::Handle->new();\nif ($fh ~~ /\\bIO\\b/) {\nsay \"handle smells IOish\";\n}\n\nThat's  because  it  treats  $fh  as  a string like \"IO::Handle=GLOB(0x8039e0)\", then pattern\nmatches against that.\n"
                },
                {
                    "name": "Bitwise And",
                    "content": "Binary \"&\" returns its operands ANDed together bit by bit.  Although no warning is  currently\nraised,  the  result  is  not  well defined when this operation is performed on operands that\naren't either  numbers  (see  \"Integer  Arithmetic\")  nor  bitstrings  (see  \"Bitwise  String\nOperators\").\n\nNote  that  \"&\"  has lower priority than relational operators, so for example the parentheses\nare essential in a test like\n\nprint \"Even\\n\" if ($x & 1) == 0;\n\nIf the \"bitwise\" feature is enabled via \"use feature 'bitwise'\" or  \"use  v5.28\",  then  this\noperator  always  treats  its  operands as numbers.  Before Perl 5.28 this feature produced a\nwarning in the \"experimental::bitwise\" category.\n"
                },
                {
                    "name": "Bitwise Or and Exclusive Or",
                    "content": "Binary \"|\" returns its operands ORed together bit by bit.\n\nBinary \"^\" returns its operands XORed together bit by bit.\n\nAlthough no warning is currently  raised,  the  results  are  not  well  defined  when  these\noperations  are  performed  on operands that aren't either numbers (see \"Integer Arithmetic\")\nnor bitstrings (see \"Bitwise String Operators\").\n\nNote that \"|\" and \"^\" have lower priority than  relational  operators,  so  for  example  the\nparentheses are essential in a test like\n\nprint \"false\\n\" if (8 | 2) != 10;\n\nIf  the  \"bitwise\"  feature  is enabled via \"use feature 'bitwise'\" or \"use v5.28\", then this\noperator always treats its operands as numbers.  Before Perl 5.28. this  feature  produced  a\nwarning in the \"experimental::bitwise\" category.\n"
                },
                {
                    "name": "C-style Logical And",
                    "content": "Binary  \"&&\" performs a short-circuit logical AND operation.  That is, if the left operand is\nfalse, the right operand is not even evaluated.  Scalar or list context  propagates  down  to\nthe right operand if it is evaluated.\n"
                },
                {
                    "name": "C-style Logical Or",
                    "content": "Binary  \"||\"  performs a short-circuit logical OR operation.  That is, if the left operand is\ntrue, the right operand is not even evaluated.  Scalar or list context propagates down to the\nright operand if it is evaluated.\n"
                },
                {
                    "name": "Logical Defined-Or",
                    "content": "Although it has no direct equivalent in C, Perl's \"//\" operator is  related  to  its  C-style\n\"or\".   In  fact,  it's  exactly  the same as \"||\", except that it tests the left hand side's\ndefinedness instead of its truth.  Thus, \"EXPR1 // EXPR2\" returns the  value  of  \"EXPR1\"  if\nit's  defined,  otherwise, the value of \"EXPR2\" is returned.  (\"EXPR1\" is evaluated in scalar\ncontext, \"EXPR2\" in the context of \"//\"  itself).   Usually,  this  is  the  same  result  as\n\"defined(EXPR1) ? EXPR1 : EXPR2\"  (except  that  the  ternary-operator  form can be used as a\nlvalue, while \"EXPR1 // EXPR2\" cannot).  This is very useful for providing default values for\nvariables.  If you actually want to test if at least  one  of  $x  and  $y  is  defined,  use\n\"defined($x // $y)\".\n\nThe  \"||\", \"//\" and \"&&\" operators return the last value evaluated (unlike C's \"||\" and \"&&\",\nwhich return 0 or 1).  Thus, a reasonably portable way to find out the home  directory  might\nbe:\n\n$home =  $ENV{HOME}\n// $ENV{LOGDIR}\n// (getpwuid($<))[7]\n// die \"You're homeless!\\n\";\n\nIn  particular,  this  means that you shouldn't use this for selecting between two aggregates\nfor assignment:\n\n@a = @b || @c;            # This doesn't do the right thing\n@a = scalar(@b) || @c;    # because it really means this.\n@a = @b ? @b : @c;        # This works fine, though.\n\nAs alternatives to \"&&\" and \"||\" when used for control flow, Perl provides the \"and\" and \"or\"\noperators (see below).  The short-circuit behavior is identical.  The precedence of \"and\" and\n\"or\" is much lower, however, so that you can safely use them after a  list  operator  without\nthe need for parentheses:\n\nunlink \"alpha\", \"beta\", \"gamma\"\nor gripe(), next LINE;\n\nWith the C-style operators that would have been written like this:\n\nunlink(\"alpha\", \"beta\", \"gamma\")\n|| (gripe(), next LINE);\n\nIt would be even more readable to write that this way:\n\nunless(unlink(\"alpha\", \"beta\", \"gamma\")) {\ngripe();\nnext LINE;\n}\n\nUsing \"or\" for assignment is unlikely to do what you want; see below.\n"
                },
                {
                    "name": "Range Operators",
                    "content": "Binary  \"..\"  is the range operator, which is really two different operators depending on the\ncontext.  In list context, it returns a list of values counting (up by ones)  from  the  left\nvalue  to the right value.  If the left value is greater than the right value then it returns\nthe empty list.  The range operator is useful for writing  \"foreach (1..10)\"  loops  and  for\ndoing  slice  operations  on  arrays.   In  the current implementation, no temporary array is\ncreated when the range operator is used as the  expression  in  \"foreach\"  loops,  but  older\nversions of Perl might burn a lot of memory when you write something like this:\n\nfor (1 .. 1000000) {\n# code\n}\n\nThe range operator also works on strings, using the magical auto-increment, see below.\n\nIn scalar context, \"..\" returns a boolean value.  The operator is bistable, like a flip-flop,\nand  emulates  the  line-range  (comma) operator of sed, awk, and various editors.  Each \"..\"\noperator maintains its own boolean state, even across calls to a subroutine that contains it.\nIt is false as long as its left operand is false.  Once the left operand is true,  the  range\noperator  stays  true until the right operand is true, AFTER which the range operator becomes\nfalse again.  It doesn't become false till the next time the range operator is evaluated.  It\ncan test the right operand and become false on the same evaluation  it  became  true  (as  in\nawk),  but  it still returns true once.  If you don't want it to test the right operand until\nthe next evaluation, as in sed, just use three dots (\"...\") instead of  two.   In  all  other\nregards, \"...\" behaves just like \"..\" does.\n\nThe  right  operand is not evaluated while the operator is in the \"false\" state, and the left\noperand is not evaluated while the operator is in the \"true\"  state.   The  precedence  is  a\nlittle  lower  than || and &&.  The value returned is either the empty string for false, or a\nsequence number (beginning with 1) for true.  The sequence number is  reset  for  each  range\nencountered.   The final sequence number in a range has the string \"E0\" appended to it, which\ndoesn't affect its numeric value, but gives you something  to  search  for  if  you  want  to\nexclude the endpoint.  You can exclude the beginning point by waiting for the sequence number\nto be greater than 1.\n\nIf either operand of scalar \"..\" is a constant expression, that operand is considered true if\nit is equal (\"==\") to the current input line number (the $. variable).\n\nTo  be  pedantic,  the  comparison  is actually \"int(EXPR) == int(EXPR)\", but that is only an\nissue if you use a floating point expression; when implicitly using $. as  described  in  the\nprevious  paragraph,  the comparison is \"int(EXPR) == int($.)\" which is only an issue when $.\nis set to a floating point  value  and  you  are  not  reading  from  a  file.   Furthermore,\n\"span\" .. \"spat\"  or  \"2.18 .. 3.14\" will not do what you want in scalar context because each\nof the operands are evaluated using their integer representation.\n\nExamples:\n\nAs a scalar operator:\n\nif (101 .. 200) { print; } # print 2nd hundred lines, short for\n#  if ($. == 101 .. $. == 200) { print; }\n\nnext LINE if (1 .. /^$/);  # skip header lines, short for\n#   next LINE if ($. == 1 .. /^$/);\n# (typically in a loop labeled LINE)\n\ns/^/> / if (/^$/ .. eof());  # quote body\n\n# parse mail messages\nwhile (<>) {\n$inheader =   1  .. /^$/;\n$inbody   = /^$/ .. eof;\nif ($inheader) {\n# do something\n} else { # in body\n# do something else\n}\n} continue {\nclose ARGV if eof;             # reset $. each file\n}\n\nHere's a simple example to illustrate the difference between the two range operators:\n\n@lines = (\"   - Foo\",\n\"01 - Bar\",\n\"1  - Baz\",\n\"   - Quux\");\n\nforeach (@lines) {\nif (/0/ .. /1/) {\nprint \"$\\n\";\n}\n}\n\nThis program will print only the line containing \"Bar\".  If the range operator is changed  to\n\"...\", it will also print the \"Baz\" line.\n\nAnd now some examples as a list operator:\n\nfor (101 .. 200) { print }      # print $ 100 times\n@foo = @foo[0 .. $#foo];        # an expensive no-op\n@foo = @foo[$#foo-4 .. $#foo];  # slice last 5 items\n\nBecause each operand is evaluated in integer form, \"2.18 .. 3.14\" will return two elements in\nlist context.\n\n@list = (2.18 .. 3.14); # same as @list = (2 .. 3);\n\nThe  range  operator  in list context can make use of the magical auto-increment algorithm if\nboth operands are strings, subject to the following rules:\n\n•   With one exception (below), if  both  strings  look  like  numbers  to  Perl,  the  magic\nincrement  will  not  be  applied,  and  the  strings  will  be  treated as numbers (more\nspecifically, integers) instead.\n\nFor example, \"-2\"..\"2\" is the same as -2..2, and \"2.18\"..\"3.14\" produces \"2, 3\".\n\n•   The exception to the above rule is when the left-hand string begins with 0 and is  longer\nthan one character, in this case the magic increment will be applied, even though strings\nlike \"01\" would normally look like a number to Perl.\n\nFor  example,  \"01\"..\"04\"  produces  \"01\", \"02\", \"03\", \"04\", and \"00\"..\"-1\" produces \"00\"\nthrough \"99\" - this may seem surprising, but see the following rules  for  why  it  works\nthis way.  To get dates with leading zeros, you can say:\n\n@z2 = (\"01\" .. \"31\");\nprint $z2[$mday];\n\nIf you want to force strings to be interpreted as numbers, you could say\n\n@numbers = ( 0+$first .. 0+$last );\n\nNote:  In  Perl  versions 5.30 and below, any string on the left-hand side beginning with\n\"0\", including the string \"0\" itself, would cause the magic  string  increment  behavior.\nThis  means  that on these Perl versions, \"0\"..\"-1\" would produce \"0\" through \"99\", which\nwas inconsistent with \"0..-1\", which produces  the  empty  list.  This  also  means  that\n\"0\"..\"9\" now produces a list of integers instead of a list of strings.\n\n•   If  the  initial  value  specified isn't part of a magical increment sequence (that is, a\nnon-empty string  matching  \"/^[a-zA-Z]*[0-9]*\\z/\"),  only  the  initial  value  will  be\nreturned.\n\nFor example, \"ax\"..\"az\" produces \"ax\", \"ay\", \"az\", but \"*x\"..\"az\" produces only \"*x\".\n\n•   For  other  initial  values  that  are  strings  that  do follow the rules of the magical\nincrement, the corresponding sequence will be returned.\n\nFor example, you can say\n\n@alphabet = (\"A\" .. \"Z\");\n\nto get all normal letters of the English alphabet, or\n\n$hexdigit = (0 .. 9, \"a\" .. \"f\")[$num & 15];\n\nto get a hexadecimal digit.\n\n•   If the final value specified is not in the sequence  that  the  magical  increment  would\nproduce,  the  sequence  goes  until  the next value would be longer than the final value\nspecified. If the length of the final string is shorter than the first, the empty list is\nreturned.\n\nFor example, \"a\"..\"--\" is the same as \"a\"..\"zz\", \"0\"..\"xx\" produces \"0\" through \"99\", and\n\"aaa\"..\"--\" returns the empty list.\n\nAs of Perl 5.26, the list-context range operator on strings works as expected in the scope of\n\"use feature 'unicodestrings\". In previous versions, and outside the scope of that  feature,\nit exhibits \"The \"Unicode Bug\"\" in perlunicode: its behavior depends on the internal encoding\nof the range endpoint.\n\nBecause    the    magical    increment    only    works   on   non-empty   strings   matching\n\"/^[a-zA-Z]*[0-9]*\\z/\", the following will only return an alpha:\n\nuse charnames \"greek\";\nmy @greeksmall =  (\"\\N{alpha}\" .. \"\\N{omega}\");\n\nTo get the 25 traditional lowercase Greek letters, including both sigmas, you could use  this\ninstead:\n\nuse charnames \"greek\";\nmy @greeksmall =  map { chr } ( ord(\"\\N{alpha}\")\n..\nord(\"\\N{omega}\")\n);\n\nHowever,  because  there  are many other lowercase Greek characters than just those, to match\nlowercase  Greek  characters  in  a  regular  expression,   you   could   use   the   pattern\n\"/(?:(?=\\p{Greek})\\p{Lower})+/\"          (or         the         experimental         feature\n\"/(?[ \\p{Greek} & \\p{Lower} ])+/\").\n"
                },
                {
                    "name": "Conditional Operator",
                    "content": "Ternary \"?:\" is the conditional operator, just as in C.  It works much like an  if-then-else.\nIf  the  argument  before the \"?\" is true, the argument before the \":\" is returned, otherwise\nthe argument after the \":\" is returned.  For example:\n\nprintf \"I have %d dog%s.\\n\", $n,\n($n == 1) ? \"\" : \"s\";\n\nScalar or list context propagates downward  into  the  2nd  or  3rd  argument,  whichever  is\nselected.\n\n$x = $ok ? $y : $z;  # get a scalar\n@x = $ok ? @y : @z;  # get an array\n$x = $ok ? @y : @z;  # oops, that's just a count!\n\nThe  operator may be assigned to if both the 2nd and 3rd arguments are legal lvalues (meaning\nthat you can assign to them):\n\n($xory ? $x : $y) = $z;\n\nBecause this operator produces an assignable result, using  assignments  without  parentheses\nwill get you in trouble.  For example, this:\n\n$x % 2 ? $x += 10 : $x += 2\n\nReally means this:\n\n(($x % 2) ? ($x += 10) : $x) += 2\n\nRather than this:\n\n($x % 2) ? ($x += 10) : ($x += 2)\n\nThat should probably be written more simply as:\n\n$x += ($x % 2) ? 10 : 2;\n"
                },
                {
                    "name": "Assignment Operators",
                    "content": "\"=\" is the ordinary assignment operator.\n\nAssignment operators work as in C.  That is,\n\n$x += 2;\n\nis equivalent to\n\n$x = $x + 2;\n\nalthough  without  duplicating  any side effects that dereferencing the lvalue might trigger,\nsuch  as  from  tie().   Other  assignment  operators  work  similarly.   The  following  are\nrecognized:\n\n=    +=    *=    &=    &.=    <<=    &&=\n-=    /=    |=    |.=    >>=    ||=\n.=    %=    ^=    ^.=           //=\nx=\n\nAlthough  these  are  grouped  by  family, they all have the precedence of assignment.  These\ncombined assignment operators can only operate on scalars, whereas  the  ordinary  assignment\noperator  can  assign to arrays, hashes, lists and even references.  (See \"Context\" and \"List\nvalue constructors\" in perldata, and \"Assigning to References\" in perlref.)\n\nUnlike in C, the scalar assignment operator produces a valid lvalue.  Modifying an assignment\nis equivalent to doing the assignment and then modifying the variable that was  assigned  to.\nThis is useful for modifying a copy of something, like this:\n\n($tmp = $global) =~ tr/13579/24680/;\n\nAlthough as of 5.14, that can be also be accomplished this way:\n\nuse v5.14;\n$tmp = ($global =~  tr/13579/24680/r);\n\nLikewise,\n\n($x += 2) *= 3;\n\nis equivalent to\n\n$x += 2;\n$x *= 3;\n\nSimilarly,  a list assignment in list context produces the list of lvalues assigned to, and a\nlist assignment in scalar context returns the number of elements produced by  the  expression\non the right hand side of the assignment.\n\nThe  three dotted bitwise assignment operators (\"&.=\" \"|.=\" \"^.=\") are new in Perl 5.22.  See\n\"Bitwise String Operators\".\n"
                },
                {
                    "name": "Comma Operator",
                    "content": "Binary \",\" is the comma operator.  In scalar context it evaluates its left  argument,  throws\nthat value away, then evaluates its right argument and returns that value.  This is just like\nC's comma operator.\n\nIn  list  context, it's just the list argument separator, and inserts both its arguments into\nthe list.  These arguments are also evaluated from left to right.\n\nThe \"=>\" operator (sometimes pronounced \"fat comma\") is a synonym for the comma  except  that\nit  causes  a  word  on  its left to be interpreted as a string if it begins with a letter or\nunderscore and is composed only of letters, digits and underscores.  This  includes  operands\nthat  might  otherwise  be  interpreted  as  operators, constants, single number v-strings or\nfunction calls.  If in doubt about this behavior, the left operand can be quoted explicitly.\n\nOtherwise, the \"=>\"  operator  behaves  exactly  as  the  comma  operator  or  list  argument\nseparator, according to context.\n\nFor example:\n\nuse constant FOO => \"something\";\n\nmy %h = ( FOO => 23 );\n\nis equivalent to:\n\nmy %h = (\"FOO\", 23);\n\nIt is NOT:\n\nmy %h = (\"something\", 23);\n\nThe  \"=>\"  operator  is  helpful in documenting the correspondence between keys and values in\nhashes, and other paired elements in lists.\n\n%hash = ( $key => $value );\nlogin( $username => $password );\n\nThe special quoting behavior ignores precedence, and hence may apply  to  part  of  the  left\noperand:\n\nprint time.shift => \"bbb\";\n\nThat  example  prints something like \"1314363215shiftbbb\", because the \"=>\" implicitly quotes\nthe \"shift\" immediately on its left, ignoring the fact that \"time.shift\" is the  entire  left\noperand.\n"
                },
                {
                    "name": "List Operators (Rightward)",
                    "content": "On  the  right  side  of  a  list  operator,  the comma has very low precedence, such that it\ncontrols all  comma-separated  expressions  found  there.   The  only  operators  with  lower\nprecedence  are  the  logical operators \"and\", \"or\", and \"not\", which may be used to evaluate\ncalls to list operators without the need for parentheses:\n\nopen HANDLE, \"< :encoding(UTF-8)\", \"filename\"\nor die \"Can't open: $!\\n\";\n\nHowever, some people find that code harder to read than writing it with parentheses:\n\nopen(HANDLE, \"< :encoding(UTF-8)\", \"filename\")\nor die \"Can't open: $!\\n\";\n\nin which case you might as well just use the more customary \"||\" operator:\n\nopen(HANDLE, \"< :encoding(UTF-8)\", \"filename\")\n|| die \"Can't open: $!\\n\";\n\nSee also discussion of list operators in \"Terms and List Operators (Leftward)\".\n"
                },
                {
                    "name": "Logical Not",
                    "content": "Unary \"not\" returns the logical negation of the expression to its right.  It's the equivalent\nof \"!\" except for the very low precedence.\n"
                },
                {
                    "name": "Logical And",
                    "content": "Binary \"and\" returns the logical  conjunction  of  the  two  surrounding  expressions.   It's\nequivalent  to  \"&&\"  except for the very low precedence.  This means that it short-circuits:\nthe right expression is evaluated only if the left expression is true.\n"
                },
                {
                    "name": "Logical or and Exclusive Or",
                    "content": "Binary \"or\" returns the  logical  disjunction  of  the  two  surrounding  expressions.   It's\nequivalent  to  \"||\"  except  for  the very low precedence.  This makes it useful for control\nflow:\n\nprint FH $data              or die \"Can't write to FH: $!\";\n\nThis means that it short-circuits: the  right  expression  is  evaluated  only  if  the  left\nexpression  is  false.   Due  to  its  precedence,  you  must be careful to avoid using it as\nreplacement for the \"||\" operator.  It usually works out better  for  flow  control  than  in\nassignments:\n\n$x = $y or $z;              # bug: this is wrong\n($x = $y) or $z;            # really means this\n$x = $y || $z;              # better written this way\n\nHowever,  when it's a list-context assignment and you're trying to use \"||\" for control flow,\nyou probably need \"or\" so that the assignment takes higher precedence.\n\n@info = stat($file) || die;     # oops, scalar sense of stat!\n@info = stat($file) or die;     # better, now @info gets its due\n\nThen again, you could always use parentheses.\n\nBinary \"xor\" returns the exclusive-OR of the two surrounding expressions.  It  cannot  short-\ncircuit (of course).\n\nThere is no low precedence operator for defined-OR.\n"
                },
                {
                    "name": "C Operators Missing From Perl",
                    "content": "Here is what C has that Perl doesn't:\n\nunary & Address-of operator.  (But see the \"\\\" operator for taking a reference.)\n\nunary * Dereference-address operator.  (Perl's prefix dereferencing operators are typed: \"$\",\n\"@\", \"%\", and \"&\".)\n\n(TYPE)  Type-casting operator.\n"
                },
                {
                    "name": "Quote and Quote-like Operators",
                    "content": "While  we  usually  think  of  quotes  as literal values, in Perl they function as operators,\nproviding various kinds of interpolating and pattern matching  capabilities.   Perl  provides\ncustomary  quote  characters  for  these behaviors, but also provides a way for you to choose\nyour quote character for any of them.  In the following table, a \"{}\" represents any pair  of\ndelimiters you choose.\n\nCustomary  Generic        Meaning        Interpolates\n''       q{}          Literal             no\n\"\"      qq{}          Literal             yes\n``      qx{}          Command             yes*\nqw{}         Word list            no\n//       m{}       Pattern match          yes*\nqr{}          Pattern             yes*\ns{}{}      Substitution          yes*\ntr{}{}    Transliteration         no (but see below)\ny{}{}    Transliteration         no (but see below)\n<<EOF                 here-doc            yes*\n\n* unless the delimiter is ''.\n\nNon-bracketing  delimiters  use  the same character fore and aft, but the four sorts of ASCII\nbrackets (round, angle, square, curly) all nest, which means that\n\nq{foo{bar}baz}\n\nis the same as\n\n'foo{bar}baz'\n\nNote, however, that this does not always work for quoting Perl code:\n\n$s = q{ if($x eq \"}\") ... }; # WRONG\n\nis a syntax error.  The \"Text::Balanced\" module (standard as of v5.8, and  from  CPAN  before\nthen) is able to do this properly.\n\nThere  can  (and  in  some  cases,  must)  be whitespace between the operator and the quoting\ncharacters, except when \"#\" is being used as the quoting character.  \"q#foo#\"  is  parsed  as\nthe  string  \"foo\",  while \"q #foo#\" is the operator \"q\" followed by a comment.  Its argument\nwill be taken from the next line.  This allows you to write:\n\ns {foo}  # Replace foo\n{bar}  # with bar.\n\nThe cases where whitespace must be used are when the quoting character is  a  word  character\n(meaning it matches \"/\\w/\"):\n\nq XfooX # Works: means the string 'foo'\nqXfooX  # WRONG!\n\nThe  following  escape  sequences  are  available  in  constructs  that  interpolate,  and in\ntransliterations whose delimiters aren't single quotes (\"'\").  In all the ones  with  braces,\nany number of blanks and/or tabs adjoining and within the braces are allowed (and ignored).\n\nSequence     Note  Description\n\\t                  tab               (HT, TAB)\n\\n                  newline           (NL)\n\\r                  return            (CR)\n\\f                  form feed         (FF)\n\\b                  backspace         (BS)\n\\a                  alarm (bell)      (BEL)\n\\e                  escape            (ESC)\n\\x{263A}     [1,8]  hex char          (example shown: SMILEY)\n\\x{ 263A }          Same, but shows optional blanks inside and\nadjoining the braces\n\\x1b         [2,8]  restricted range hex char (example: ESC)\n\\N{name}     [3]    named Unicode character or character sequence\n\\N{U+263D}   [4,8]  Unicode character (example: FIRST QUARTER MOON)\n\\c[          [5]    control char      (example: chr(27))\n\\o{23072}    [6,8]  octal char        (example: SMILEY)\n\\033         [7,8]  restricted range octal char  (example: ESC)\n\nNote  that  any escape sequence using braces inside interpolated constructs may have optional\nblanks (tab or space characters) adjoining with and inside  of  the  braces,  as  illustrated\nabove by the second \"\\x{ }\" example.\n\n[1] The  result is the character specified by the hexadecimal number between the braces.  See\n\"[8]\" below for details on which character.\n\nBlanks (tab or space characters) may separate the number  from  either  or  both  of  the\nbraces.\n\nOtherwise, only hexadecimal digits are valid between the braces.  If an invalid character\nis  encountered,  a  warning  will be issued and the invalid character and all subsequent\ncharacters (valid or invalid) within the braces will be discarded.\n\nIf there are no valid digits between the braces, the  generated  character  is  the  NULL\ncharacter (\"\\x{00}\").  However, an explicit empty brace (\"\\x{}\") will not cause a warning\n(currently).\n\n[2] The  result  is  the  character  specified by the hexadecimal number in the range 0x00 to\n0xFF.  See \"[8]\" below for details on which character.\n\nOnly hexadecimal digits are valid following \"\\x\".  When \"\\x\" is followed  by  fewer  than\ntwo  valid  digits,  any valid digits will be zero-padded.  This means that \"\\x7\" will be\ninterpreted as \"\\x07\", and a lone \"\\x\" will be interpreted as \"\\x00\".  Except at the  end\nof  a  string,  having  fewer  than two valid digits will result in a warning.  Note that\nalthough the warning says the illegal character is ignored, it is only ignored as part of\nthe escape and will still be used  as  the  subsequent  character  in  the  string.   For\nexample:\n\nOriginal    Result    Warns?\n\"\\x7\"       \"\\x07\"    no\n\"\\x\"        \"\\x00\"    no\n\"\\x7q\"      \"\\x07q\"   yes\n\"\\xq\"       \"\\x00q\"   yes\n\n[3] The result is the Unicode character or character sequence given by name.  See charnames.\n\n[4] \"\\N{U+hexadecimal number}\"  means  the  Unicode  character  whose  Unicode  code point is\nhexadecimal number.\n\n[5] The character following \"\\c\" is mapped to some other character as shown in the table:\n\nSequence   Value\n\\c@      chr(0)\n\\cA      chr(1)\n\\ca      chr(1)\n\\cB      chr(2)\n\\cb      chr(2)\n...\n\\cZ      chr(26)\n\\cz      chr(26)\n\\c[      chr(27)\n# See below for chr(28)\n\\c]      chr(29)\n\\c^      chr(30)\n\\c      chr(31)\n\\c?      chr(127) # (on ASCII platforms; see below for link to\n#  EBCDIC discussion)\n\nIn other words, it's the character whose code point has had 64 xor'd with its  uppercase.\n\"\\c?\"  is  DELETE  on  ASCII  platforms because \"ord(\"?\") ^ 64\" is 127, and \"\\c@\" is NULL\nbecause the ord of \"@\" is 64, so xor'ing 64 itself produces 0.\n\nAlso, \"\\c\\X\" yields \" chr(28) . \"X\"\" for any X, but cannot come at the end of  a  string,\nbecause the backslash would be parsed as escaping the end quote.\n\nOn  ASCII platforms, the resulting characters from the list above are the complete set of\nASCII controls.  This isn't the case on EBCDIC platforms; see \"OPERATOR  DIFFERENCES\"  in\nperlebcdic for a full discussion of the differences between these for ASCII versus EBCDIC\nplatforms.\n\nUse  of  any other character following the \"c\" besides those listed above is discouraged,\nand as of Perl v5.20, the only characters actually allowed are the printable ASCII  ones,\nminus  the  left brace \"{\".  What happens for any of the allowed other characters is that\nthe value is derived by xor'ing with the seventh bit, which is 64, and a  warning  raised\nif enabled.  Using the non-allowed characters generates a fatal error.\n\nTo get platform independent controls, you can use \"\\N{...}\".\n\n[6] The  result is the character specified by the octal number between the braces.  See \"[8]\"\nbelow for details on which character.\n\nBlanks (tab or space characters) may separate the number  from  either  or  both  of  the\nbraces.\n\nOtherwise,  if a character that isn't an octal digit is encountered, a warning is raised,\nand the value is based on the octal digits before it, discarding  it  and  all  following\ncharacters  up to the closing brace.  It is a fatal error if there are no octal digits at\nall.\n\n[7] The result is the character specified by the three-digit octal number in the range 000 to\n777 (but best to not use above 077, see next paragraph).  See \"[8]\" below for details  on\nwhich character.\n\nSome  contexts  allow  2 or even 1 digit, but any usage without exactly three digits, the\nfirst being a zero, may give unintended results.  (For example, in a  regular  expression\nit  may  be  confused  with  a  backreference;  see  \"Octal escapes\" in perlrebackslash.)\nStarting in Perl 5.14, you may use \"\\o{}\"  instead,  which  avoids  all  these  problems.\nOtherwise,  it  is  best  to  use  this  construct  only  for  ordinals \"\\077\" and below,\nremembering to pad to the left with zeros to make three  digits.   For  larger  ordinals,\neither  use  \"\\o{}\", or convert to something else, such as to hex and use \"\\N{U+}\" (which\nis portable between platforms with different character sets) or \"\\x{}\" instead.\n\n[8] Several constructs above specify  a  character  by  a  number.   That  number  gives  the\ncharacter's  position  in  the  character  set encoding (indexed from 0).  This is called\nsynonymously its ordinal, code position, or code point.  Perl  works  on  platforms  that\nhave  a  native  encoding currently of either ASCII/Latin1 or EBCDIC, each of which allow\nspecification of 256 characters.  In general, if the number is 255 (0xFF, 0377) or below,\nPerl interprets this in the platform's native encoding.  If the  number  is  256  (0x100,\n0400)  or  above,  Perl  interprets  it  as  a  Unicode  code point and the result is the\ncorresponding Unicode character.  For example \"\\x{50}\" and \"\\o{120}\" both are the  number\n80  in  decimal,  which  is  less  than  256,  so the number is interpreted in the native\ncharacter set encoding.  In ASCII the character in the 80th position (indexed from 0)  is\nthe  letter  \"P\",  and in EBCDIC it is the ampersand symbol \"&\".  \"\\x{100}\" and \"\\o{400}\"\nare both 256 in decimal, so the number is interpreted as a Unicode code point  no  matter\nwhat the native encoding is.  The name of the character in the 256th position (indexed by\n0) in Unicode is \"LATIN CAPITAL LETTER A WITH MACRON\".\n\nAn  exception  to  the  above  rule is that \"\\N{U+hex number}\" is always interpreted as a\nUnicode code point, so that \"\\N{U+0050}\" is \"P\" even on EBCDIC platforms.\n\nNOTE: Unlike C and other languages, Perl has no \"\\v\" escape sequence  for  the  vertical  tab\n(VT,  which  is 11 in both ASCII and EBCDIC), but you may use \"\\N{VT}\", \"\\ck\", \"\\N{U+0b}\", or\n\"\\x0b\".  (\"\\v\" does have meaning in regular expression patterns in Perl, see perlre.)\n\nThe following escape sequences are available in  constructs  that  interpolate,  but  not  in\ntransliterations.\n\n\\l          lowercase next character only\n\\u          titlecase (not uppercase!) next character only\n\\L          lowercase all characters till \\E or end of string\n\\U          uppercase all characters till \\E or end of string\n\\F          foldcase all characters till \\E or end of string\n\\Q          quote (disable) pattern metacharacters till \\E or\nend of string\n\\E          end either case modification or quoted section\n(whichever was last seen)\n\nSee \"quotemeta\" in perlfunc for the exact definition of characters that are quoted by \"\\Q\".\n\n\"\\L\", \"\\U\", \"\\F\", and \"\\Q\" can stack, in which case you need one \"\\E\" for each.  For example:\n\nsay \"This \\Qquoting \\ubusiness \\Uhere isn't quite\\E done yet,\\E is it?\";\nThis quoting\\ Business\\ HERE\\ ISN\\'T\\ QUITE\\ done\\ yet\\, is it?\n\nIf  a  \"use locale\" form that includes \"LCCTYPE\" is in effect (see perllocale), the case map\nused by \"\\l\", \"\\L\", \"\\u\", and \"\\U\" is  taken  from  the  current  locale.   If  Unicode  (for\nexample,  \"\\N{}\" or code points of 0x100 or beyond) is being used, the case map used by \"\\l\",\n\"\\L\", \"\\u\", and \"\\U\" is as defined  by  Unicode.   That  means  that  case-mapping  a  single\ncharacter  can  sometimes produce a sequence of several characters.  Under \"use locale\", \"\\F\"\nproduces the same results as \"\\L\" for all locales but a UTF-8 one, where it instead uses  the\nUnicode definition.\n\nAll  systems  use the virtual \"\\n\" to represent a line terminator, called a \"newline\".  There\nis no such thing as an unvarying, physical newline character.  It is only  an  illusion  that\nthe  operating  system,  device drivers, C libraries, and Perl all conspire to preserve.  Not\nall systems read \"\\r\" as ASCII CR and \"\\n\" as ASCII LF.  For example,  on  the  ancient  Macs\n(pre-MacOS  X)  of  yesteryear,  these  used  to  be  reversed, and on systems without a line\nterminator, printing \"\\n\" might emit no actual data.  In general, use \"\\n\" when  you  mean  a\n\"newline\"  for  your system, but use the literal ASCII when you need an exact character.  For\nexample, most networking protocols expect and prefer a CR+LF  (\"\\015\\012\"  or  \"\\cM\\cJ\")  for\nline  terminators,  and  although  they  often  accept just \"\\012\", they seldom tolerate just\n\"\\015\".  If you get in the habit of using \"\\n\" for networking, you may be burned some day.\n\nFor constructs that do interpolate, variables beginning with \"\"$\"\" or \"\"@\"\" are interpolated.\nSubscripted variables such as $a[3] or \"$href->{key}[0]\" are also interpolated, as are  array\nand hash slices.  But method calls such as \"$obj->meth\" are not.\n\nInterpolating an array or slice interpolates the elements in order, separated by the value of\n$\",  so  is equivalent to interpolating \"join $\", @array\".  \"Punctuation\" arrays such as \"@*\"\nare usually interpolated only if the name is enclosed in braces \"@{*}\", but  the  arrays  @,\n\"@+\", and \"@-\" are interpolated even without braces.\n\nFor  double-quoted  strings, the quoting from \"\\Q\" is applied after interpolation and escapes\nare processed.\n\n\"abc\\Qfoo\\tbar$s\\Exyz\"\n\nis equivalent to\n\n\"abc\" . quotemeta(\"foo\\tbar$s\") . \"xyz\"\n\nFor the pattern of regex operators (\"qr//\", \"m//\" and  \"s///\"),  the  quoting  from  \"\\Q\"  is\napplied  after interpolation is processed, but before escapes are processed.  This allows the\npattern to match literally (except for \"$\" and \"@\").  For example, the following matches:\n\n'\\s\\t' =~ /\\Q\\s\\t/\n\nBecause  \"$\"  or  \"@\"  trigger   interpolation,   you'll   need   to   use   something   like\n\"/\\Quser\\E\\@\\Qhost/\" to match them literally.\n\nPatterns  are subject to an additional level of interpretation as a regular expression.  This\nis done as a second pass, after variables are interpolated, so that regular  expressions  may\nbe  incorporated into the pattern from the variables.  If this is not what you want, use \"\\Q\"\nto interpolate a variable literally.\n\nApart  from  the  behavior  described  above,  Perl  does  not  expand  multiple  levels   of\ninterpolation.  In particular, contrary to the expectations of shell programmers, back-quotes\ndo  NOT interpolate within double quotes, nor do single quotes impede evaluation of variables\nwhen used within double quotes.\n"
                },
                {
                    "name": "Regexp Quote-Like Operators",
                    "content": "Here are the quote-like operators that apply to pattern matching and related activities.\n\n\"qr/STRING/msixpodualn\"\nThis operator quotes (and possibly compiles) its  STRING  as  a  regular  expression.\nSTRING  is  interpolated  the same way as PATTERN in \"m/PATTERN/\".  If \"'\" is used as\nthe delimiter, no variable interpolation is done.  Returns a Perl value which may  be\nused  instead  of  the  corresponding \"/STRING/msixpodualn\" expression.  The returned\nvalue is a normalized version of the original pattern.  It magically differs  from  a\nstring   containing  the  same  characters:  ref(qr/x/)  returns  \"Regexp\";  however,\ndereferencing it is not well defined (you currently get the normalized version of the\noriginal pattern, but this may change).\n\nFor example,\n\n$rex = qr/my.STRING/is;\nprint $rex;                 # prints (?si-xm:my.STRING)\ns/$rex/foo/;\n\nis equivalent to\n\ns/my.STRING/foo/is;\n\nThe result may be used as a subpattern in a match:\n\n$re = qr/$pattern/;\n$string =~ /foo${re}bar/;   # can be interpolated in other\n# patterns\n$string =~ $re;             # or used standalone\n$string =~ /$re/;           # or this way\n\nSince Perl may compile the pattern at the moment of execution of the  qr()  operator,\nusing  qr()  may  have  speed advantages in some situations, notably if the result of\nqr() is used standalone:\n\nsub match {\nmy $patterns = shift;\nmy @compiled = map qr/$/i, @$patterns;\ngrep {\nmy $success = 0;\nforeach my $pat (@compiled) {\n$success = 1, last if /$pat/;\n}\n$success;\n} @;\n}\n\nPrecompilation of the pattern into an internal representation at the moment  of  qr()\navoids  the  need  to recompile the pattern every time a match \"/$pat/\" is attempted.\n(Perl has many other internal optimizations, but none would be triggered in the above\nexample if we did not use qr() operator.)\n\nOptions (specified by the following modifiers) are:\n\nm   Treat string as multiple lines.\ns   Treat string as single line. (Make . match a newline)\ni   Do case-insensitive pattern matching.\nx   Use extended regular expressions; specifying two\nx's means \\t and the SPACE character are ignored within\nsquare-bracketed character classes\np   When matching preserve a copy of the matched string so\nthat ${^PREMATCH}, ${^MATCH}, ${^POSTMATCH} will be\ndefined (ignored starting in v5.20 as these are always\ndefined starting in that release)\no   Compile pattern only once.\na   ASCII-restrict: Use ASCII for \\d, \\s, \\w and [[:posix:]]\ncharacter classes; specifying two a's adds the further\nrestriction that no ASCII character will match a\nnon-ASCII one under /i.\nl   Use the current run-time locale's rules.\nu   Use Unicode rules.\nd   Use Unicode or native charset, as in 5.12 and earlier.\nn   Non-capture mode. Don't let () fill in $1, $2, etc...\n\nIf a precompiled pattern  is  embedded  in  a  larger  pattern  then  the  effect  of\n\"msixpluadn\" will be propagated appropriately.  The effect that the \"/o\" modifier has\nis not propagated, being restricted to those patterns explicitly using it.\n\nThe  \"/a\",  \"/d\", \"/l\", and \"/u\" modifiers (added in Perl 5.14) control the character\nset rules, but \"/a\" is the only one you are likely to want to specify explicitly; the\nother three are selected automatically by various pragmas.\n\nSee perlre for additional information on valid syntax for STRING, and for a  detailed\nlook  at  the  semantics of regular expressions.  In particular, all modifiers except\nthe largely obsolete \"/o\" are further explained in \"Modifiers\" in  perlre.   \"/o\"  is\ndescribed in the next section.\n\n\"m/PATTERN/msixpodualngc\"\n\"/PATTERN/msixpodualngc\"\nSearches  a  string  for  a  pattern  match, and in scalar context returns true if it\nsucceeds, false if it fails.  If  no  string  is  specified  via  the  \"=~\"  or  \"!~\"\noperator,  the $ string is searched.  (The string specified with \"=~\" need not be an\nlvalue--it may be the result of an expression evaluation, but remember the \"=~\" binds\nrather tightly.)  See also perlre.\n\nOptions are as described in \"qr//\" above; in addition, the  following  match  process\nmodifiers are available:\n\ng  Match globally, i.e., find all occurrences.\nc  Do not reset search position on a failed match when /g is\nin effect.\n\nIf  \"/\"  is the delimiter then the initial \"m\" is optional.  With the \"m\" you can use\nany pair of non-whitespace (ASCII) characters as delimiters.   This  is  particularly\nuseful  for  matching  path  names  that contain \"/\", to avoid LTS (leaning toothpick\nsyndrome).  If \"?\" is the delimiter, then a match-only-once rule  applies,  described\nin  \"m?PATTERN?\"  below.   If  \"'\"  (single  quote)  is  the  delimiter,  no variable\ninterpolation is performed on the PATTERN.  When using a delimiter character valid in\nan identifier, whitespace is required after the \"m\".\n\nPATTERN may contain variables, which will be  interpolated  every  time  the  pattern\nsearch is evaluated, except for when the delimiter is a single quote.  (Note that $(,\n$),  and  $|  are not interpolated because they look like end-of-string tests.)  Perl\nwill not recompile the pattern unless  an  interpolated  variable  that  it  contains\nchanges.   You  can  force Perl to skip the test and never recompile by adding a \"/o\"\n(which stands for \"once\") after the trailing delimiter.  Once upon a time, Perl would\nrecompile regular expressions unnecessarily, and this modifier was useful to tell  it\nnot  to  do so, in the interests of speed.  But now, the only reasons to use \"/o\" are\none of:\n\n1.  The variables are thousands of characters long  and  you  know  that  they  don't\nchange,  and  you  need  to wring out the last little bit of speed by having Perl\nskip testing for that.  (There is  a  maintenance  penalty  for  doing  this,  as\nmentioning  \"/o\" constitutes a promise that you won't change the variables in the\npattern.  If you do change them, Perl won't even notice.)\n\n2.  you want the pattern to use the initial values of  the  variables  regardless  of\nwhether they change or not.  (But there are saner ways of accomplishing this than\nusing \"/o\".)\n\n3.  If the pattern contains embedded code, such as\n\nuse re 'eval';\n$code = 'foo(?{ $x })';\n/$code/\n\nthen  perl  will  recompile  each  time,  even  though  the pattern string hasn't\nchanged, to ensure that the current value of $x is seen each time.  Use  \"/o\"  if\nyou want to avoid this.\n\nThe bottom line is that using \"/o\" is almost never a good idea.\n\nThe empty pattern \"//\"\nIf  the  PATTERN evaluates to the empty string, the last successfully matched regular\nexpression is used instead. In this case, only the \"g\" and \"c\"  flags  on  the  empty\npattern are honored; the other flags are taken from the original pattern. If no match\nhas previously succeeded, this will (silently) act instead as a genuine empty pattern\n(which  will  always  match).  Using a user supplied string as a pattern has the risk\nthat if the string is empty that it triggers the \"last  successful  match\"  behavior,\nwhich  can  be  very  confusing.  In  such  cases  you  are  recommended  to  replace\n\"m/$pattern/\" with \"m/(?:$pattern)/\" to avoid this behavior.\n\nThe   last   successful   pattern   may   be   accessed    as    a    variable    via\n\"${^LASTSUCCESSFULPATTERN}\".  Matching against it, or the empty pattern should have\nthe same effect, with the exception that when there is no last successful pattern the\nempty pattern will silently match, whereas  using  the  \"${^LASTSUCCESSFULPATTERN}\"\nvariable  will  produce  undefined  warnings (if warnings are enabled). You can check\ndefined(${^LASTSUCCESSFULPATTERN}) to test if there is a \"last successful match\" in\nthe current scope.\n\nNote that it's possible to confuse Perl into  thinking  \"//\"  (the  empty  regex)  is\nreally  \"//\"  (the defined-or operator).  Perl is usually pretty good about this, but\nsome pathological cases might trigger this, such as \"$x///\" (is that \"($x) / (//)\" or\n\"$x // /\"?) and \"print $fh //\" (\"print $fh(//\" or \"print($fh //\"?).  In all of  these\nexamples,  Perl will assume you meant defined-or.  If you meant the empty regex, just\nuse parentheses or spaces to disambiguate, or even prefix the empty regex with an \"m\"\n(so \"//\" becomes \"m//\").\n\nMatching in list context\nIf the \"/g\" option is not used, \"m//\" in list context returns a  list  consisting  of\nthe  subexpressions  matched  by  the  parentheses  in the pattern, that is, ($1, $2,\n$3...)  (Note that here $1 etc. are also set).  When there are no parentheses in  the\npattern,  the  return  value  is  the  list  \"(1)\"  for  success.   With  or  without\nparentheses, an empty list is returned upon failure.\n\nExamples:\n\nopen(TTY, \"+</dev/tty\")\n|| die \"can't access /dev/tty: $!\";\n\n<TTY> =~ /^y/i && foo();       # do foo if desired\n\nif (/Version: *([0-9.]*)/) { $version = $1; }\n\nnext if m#^/usr/spool/uucp#;\n\n# poor man's grep\n$arg = shift;\nwhile (<>) {\nprint if /$arg/o; # compile only once (no longer needed!)\n}\n\nif (($F1, $F2, $Etc) = ($foo =~ /^(\\S+)\\s+(\\S+)\\s*(.*)/))\n\nThis last example splits $foo into the first two words and the remainder of the line,\nand assigns those three fields to $F1, $F2, and $Etc.  The conditional is true if any\nvariables were assigned; that is, if the pattern matched.\n\nThe \"/g\" modifier specifies global pattern matching--that is, matching as many  times\nas  possible  within  the  string.   How  it behaves depends on the context.  In list\ncontext, it returns a list of the substrings matched by any capturing parentheses  in\nthe  regular  expression.   If there are no parentheses, it returns a list of all the\nmatched strings, as if there were parentheses around the whole pattern.\n\nIn scalar context, each execution of \"m//g\" finds the next match, returning  true  if\nit  matches,  and  false  if  there is no further match.  The position after the last\nmatch can be read or set using the pos() function; see \"pos\" in perlfunc.   A  failed\nmatch normally resets the search position to the beginning of the string, but you can\navoid  that by adding the \"/c\" modifier (for example, \"m//gc\").  Modifying the target\nstring also resets the search position.\n\n\"\\G assertion\"\nYou can intermix  \"m//g\"  matches  with  \"m/\\G.../g\",  where  \"\\G\"  is  a  zero-width\nassertion  that  matches  the  exact position where the previous \"m//g\", if any, left\noff.  Without the \"/g\" modifier, the \"\\G\" assertion still anchors at pos() as it  was\nat  the  start  of  the operation (see \"pos\" in perlfunc), but the match is of course\nonly attempted once.  Using \"\\G\" without  \"/g\"  on  a  target  string  that  has  not\npreviously  had a \"/g\" match applied to it is the same as using the \"\\A\" assertion to\nmatch the beginning of the string.  Note also that, currently, \"\\G\" is only  properly\nsupported when anchored at the very beginning of the pattern.\n\nExamples:\n\n# list context\n($one,$five,$fifteen) = (`uptime` =~ /(\\d+\\.\\d+)/g);\n\n# scalar context\nlocal $/ = \"\";\nwhile ($paragraph = <>) {\nwhile ($paragraph =~ /\\p{Ll}['\")]*[.!?]+['\")]*\\s/g) {\n$sentences++;\n}\n}\nsay $sentences;\n\nHere's another way to check for sentences in a paragraph:\n\nmy $sentencerx = qr{\n(?: (?<= ^ ) | (?<= \\s ) )  # after start-of-string or\n# whitespace\n\\p{Lu}                      # capital letter\n.*?                         # a bunch of anything\n(?<= \\S )                   # that ends in non-\n# whitespace\n(?<! \\b [DMS]r  )           # but isn't a common abbr.\n(?<! \\b Mrs )\n(?<! \\b Sra )\n(?<! \\b St  )\n[.?!]                       # followed by a sentence\n# ender\n(?= $ | \\s )                # in front of end-of-string\n# or whitespace\n}sx;\nlocal $/ = \"\";\nwhile (my $paragraph = <>) {\nsay \"NEW PARAGRAPH\";\nmy $count = 0;\nwhile ($paragraph =~ /($sentencerx)/g) {\nprintf \"\\tgot sentence %d: <%s>\\n\", ++$count, $1;\n}\n}\n\nHere's how to use \"m//gc\" with \"\\G\":\n\n$ = \"ppooqppqq\";\nwhile ($i++ < 2) {\nprint \"1: '\";\nprint $1 while /(o)/gc; print \"', pos=\", pos, \"\\n\";\nprint \"2: '\";\nprint $1 if /\\G(q)/gc;  print \"', pos=\", pos, \"\\n\";\nprint \"3: '\";\nprint $1 while /(p)/gc; print \"', pos=\", pos, \"\\n\";\n}\nprint \"Final: '$1', pos=\",pos,\"\\n\" if /\\G(.)/;\n\nThe last example should print:\n\n1: 'oo', pos=4\n2: 'q', pos=5\n3: 'pp', pos=7\n1: '', pos=7\n2: 'q', pos=8\n3: '', pos=8\nFinal: 'q', pos=8\n\nNotice  that  the  final  match matched \"q\" instead of \"p\", which a match without the\n\"\\G\" anchor would have done.  Also note that the final match did  not  update  \"pos\".\n\"pos\" is only updated on a \"/g\" match.  If the final match did indeed match \"p\", it's\na good bet that you're running an ancient (pre-5.6.0) version of Perl.\n\nA  useful  idiom  for  \"lex\"-like  scanners  is \"/\\G.../gc\".  You can combine several\nregexps like this to process a string part-by-part, doing different actions depending\non which regexp matched.  Each regexp tries to match where the  previous  one  leaves\noff.\n\n$ = <<'EOL';\n$url = URI::URL->new( \"http://example.com/\" );\ndie if $url eq \"xXx\";\nEOL\n\nLOOP: {\nprint(\" digits\"),       redo LOOP if /\\G\\d+\\b[,.;]?\\s*/gc;\nprint(\" lowercase\"),    redo LOOP\nif /\\G\\p{Ll}+\\b[,.;]?\\s*/gc;\nprint(\" UPPERCASE\"),    redo LOOP\nif /\\G\\p{Lu}+\\b[,.;]?\\s*/gc;\nprint(\" Capitalized\"),  redo LOOP\nif /\\G\\p{Lu}\\p{Ll}+\\b[,.;]?\\s*/gc;\nprint(\" MiXeD\"),        redo LOOP if /\\G\\pL+\\b[,.;]?\\s*/gc;\nprint(\" alphanumeric\"), redo LOOP\nif /\\G[\\p{Alpha}\\pN]+\\b[,.;]?\\s*/gc;\nprint(\" line-noise\"),   redo LOOP if /\\G\\W+/gc;\nprint \". That's all!\\n\";\n}\n\nHere is the output (split into several lines):\n\nline-noise lowercase line-noise UPPERCASE line-noise UPPERCASE\nline-noise lowercase line-noise lowercase line-noise lowercase\nlowercase line-noise lowercase lowercase line-noise lowercase\nlowercase line-noise MiXeD line-noise. That's all!\n\n\"m?PATTERN?msixpodualngc\"\nThis  is  just like the \"m/PATTERN/\" search, except that it matches only once between\ncalls to the reset() operator.  This is a useful optimization when you  want  to  see\nonly  the first occurrence of something in each file of a set of files, for instance.\nOnly \"m??\"  patterns local to the current package are reset.\n\nwhile (<>) {\nif (m?^$?) {\n# blank line between header and body\n}\n} continue {\nreset if eof;       # clear m?? status for next file\n}\n\nAnother example switched the first \"latin1\" encoding it finds  to  \"utf8\"  in  a  pod\nfile:\n\ns//utf8/ if m? ^ =encoding \\h+ \\K latin1 ?x;\n\nThe  match-once  behavior  is  controlled  by the match delimiter being \"?\"; with any\nother delimiter this is the normal \"m//\" operator.\n\nIn the past, the leading \"m\" in \"m?PATTERN?\" was  optional,  but  omitting  it  would\nproduce  a  deprecation warning.  As of v5.22.0, omitting it produces a syntax error.\nIf you encounter this construct in older code, you can just add \"m\".\n\n\"s/PATTERN/REPLACEMENT/msixpodualngcer\"\nSearches a string for a pattern,  and  if  found,  replaces  that  pattern  with  the\nreplacement  text and returns the number of substitutions made.  Otherwise it returns\nfalse (a value that is both an empty string (\"\") and numeric zero (0) as described in\n\"Relational Operators\").\n\nIf the \"/r\" (non-destructive) option is used then it runs the substitution on a  copy\nof  the  string  and instead of returning the number of substitutions, it returns the\ncopy whether or not a substitution occurred.  The original string  is  never  changed\nwhen  \"/r\"  is used.  The copy will always be a plain string, even if the input is an\nobject or a tied variable.\n\nIf no string is specified via the \"=~\" or \"!~\" operator, the $ variable is  searched\nand  modified.  Unless the \"/r\" option is used, the string specified must be a scalar\nvariable, an array element, a hash element, or an assignment to one  of  those;  that\nis, some sort of scalar lvalue.\n\nIf  the  delimiter  chosen  is  a  single quote, no variable interpolation is done on\neither the PATTERN or the REPLACEMENT.  Otherwise, if the PATTERN contains a \"$\" that\nlooks like a variable rather  than  an  end-of-string  test,  the  variable  will  be\ninterpolated  into  the  pattern  at run-time.  If you want the pattern compiled only\nonce the first time the variable is  interpolated,  use  the  \"/o\"  option.   If  the\npattern  evaluates  to  the  empty  string,  the  last  successfully executed regular\nexpression is used instead.  See perlre for further explanation on these.\n\nOptions are as with \"m//\" with the addition of  the  following  replacement  specific\noptions:\n\ne   Evaluate the right side as an expression.\nee  Evaluate the right side as a string then eval the\nresult.\nr   Return substitution and leave the original string\nuntouched.\n\nAny  non-whitespace  delimiter may replace the slashes.  Add space after the \"s\" when\nusing  a  character  allowed  in  identifiers.   If  single  quotes  are   used,   no\ninterpretation  is  done on the replacement string (the \"/e\" modifier overrides this,\nhowever).  Note that Perl treats backticks as normal delimiters; the replacement text\nis not evaluated as a command.  If the PATTERN is delimited by bracketing quotes, the\nREPLACEMENT has its own pair of quotes, which may or may not  be  bracketing  quotes,\nfor  example,  \"s(foo)(bar)\"  or  \"s<foo>/bar/\".   A  \"/e\" will cause the replacement\nportion to be treated as a full-fledged Perl expression and evaluated right then  and\nthere.   It  is, however, syntax checked at compile-time.  A second \"e\" modifier will\ncause the replacement portion to be \"eval\"ed before being run as a Perl expression.\n\nExamples:\n\ns/\\bgreen\\b/mauve/g;              # don't change wintergreen\n\n$path =~ s|/usr/bin|/usr/local/bin|;\n\ns/Login: $foo/Login: $bar/; # run-time pattern\n\n($foo = $bar) =~ s/this/that/;      # copy first, then\n# change\n($foo = \"$bar\") =~ s/this/that/;    # convert to string,\n# copy, then change\n$foo = $bar =~ s/this/that/r;       # Same as above using /r\n$foo = $bar =~ s/this/that/r\n=~ s/that/the other/r;  # Chained substitutes\n# using /r\n@foo = map { s/this/that/r } @bar   # /r is very useful in\n# maps\n\n$count = ($paragraph =~ s/Mister\\b/Mr./g);  # get change-cnt\n\n$ = 'abc123xyz';\ns/\\d+/$&*2/e;               # yields 'abc246xyz'\ns/\\d+/sprintf(\"%5d\",$&)/e;  # yields 'abc  246xyz'\ns/\\w/$& x 2/eg;             # yields 'aabbcc  224466xxyyzz'\n\ns/%(.)/$percent{$1}/g;      # change percent escapes; no /e\ns/%(.)/$percent{$1} || $&/ge;       # expr now, so /e\ns/^=(\\w+)/pod($1)/ge;       # use function call\n\n$ = 'abc123xyz';\n$x = s/abc/def/r;           # $x is 'def123xyz' and\n# $ remains 'abc123xyz'.\n\n# expand variables in $, but dynamics only, using\n# symbolic dereferencing\ns/\\$(\\w+)/${$1}/g;\n\n# Add one to the value of any numbers in the string\ns/(\\d+)/1 + $1/eg;\n\n# Titlecase words in the last 30 characters only (presuming\n# that the substring doesn't start in the middle of a word)\nsubstr($str, -30) =~ s/\\b(\\p{Alpha})(\\p{Alpha}*)\\b/\\u$1\\L$2/g;\n\n# This will expand any embedded scalar variable\n# (including lexicals) in $ : First $1 is interpolated\n# to the variable name, and then evaluated\ns/(\\$\\w+)/$1/eeg;\n\n# Delete (most) C comments.\n$program =~ s {\n/\\*     # Match the opening delimiter.\n.*?     # Match a minimal number of characters.\n\\*/     # Match the closing delimiter.\n} []gsx;\n\ns/^\\s*(.*?)\\s*$/$1/;        # trim whitespace in $,\n# expensively\n\nfor ($variable) {           # trim whitespace in $variable,\n# cheap\ns/^\\s+//;\ns/\\s+$//;\n}\n\ns/([^ ]*) *([^ ]*)/$2 $1/;  # reverse 1st two fields\n\n$foo !~ s/A/a/g;    # Lowercase all A's in $foo; return\n# 0 if any were found and changed;\n# otherwise return 1\n\nNote the use of \"$\" instead of \"\\\" in the last  example.   Unlike  sed,  we  use  the\n\\<digit> form only in the left hand side.  Anywhere else it's $<digit>.\n\nOccasionally,  you  can't  use  just  a \"/g\" to get all the changes to occur that you\nmight want.  Here are two common cases:\n\n# put commas in the right places in an integer\n1 while s/(\\d)(\\d\\d\\d)(?!\\d)/$1,$2/g;\n\n# expand tabs to 8-column spacing\n1 while s/\\t+/' ' x (length($&)*8 - length($`)%8)/e;\n\nWhile \"s///\" accepts the \"/c\" flag, it has no effect beyond producing  a  warning  if\nwarnings are enabled.\n"
                },
                {
                    "name": "Quote-Like Operators",
                    "content": "\"q/STRING/\"\n'STRING'\nA  single-quoted,  literal string.  A backslash represents a backslash unless followed by\nthe delimiter or  another  backslash,  in  which  case  the  delimiter  or  backslash  is\ninterpolated.\n\n$foo = q!I said, \"You said, 'She said it.'\"!;\n$bar = q('This is it.');\n$baz = '\\n';                # a two-character string\n\n\"qq/STRING/\"\n\"STRING\"\nA double-quoted, interpolated string.\n\n$ .= qq\n(* The previous line contains the naughty word \"$1\".\\n)\nif /\\b(tcl|java|python)\\b/i;      # :-)\n$baz = \"\\n\";                # a one-character string\n\n\"qx/STRING/\"\n`STRING`\nA  string  which  is  (possibly)  interpolated and then executed as a system command, via\n/bin/sh or its equivalent if required.  Shell wildcards, pipes, and redirections will  be\nhonored.   Similarly  to \"system\", if the string contains no shell metacharacters then it\nwill executed directly.  The collected  standard  output  of  the  command  is  returned;\nstandard  error is unaffected.  In scalar context, it comes back as a single (potentially\nmulti-line) string, or \"undef\" if the shell (or command) could not be started.   In  list\ncontext,   returns   a   list   of  lines  (however  you've  defined  lines  with  $/  or\n$INPUTRECORDSEPARATOR), or an empty list  if  the  shell  (or  command)  could  not  be\nstarted.\n\nBecause  backticks  do  not  affect  standard  error,  use  shell  file descriptor syntax\n(assuming the shell supports this) if you care to address this.  To capture  a  command's\nSTDERR and STDOUT together:\n\n$output = `cmd 2>&1`;\n\nTo capture a command's STDOUT but discard its STDERR:\n\n$output = `cmd 2>/dev/null`;\n\nTo capture a command's STDERR but discard its STDOUT (ordering is important here):\n\n$output = `cmd 2>&1 1>/dev/null`;\n\nTo  exchange  a  command's STDOUT and STDERR in order to capture the STDERR but leave its\nSTDOUT to come out the old STDERR:\n\n$output = `cmd 3>&1 1>&2 2>&3 3>&-`;\n\nTo read both a command's STDOUT and its STDERR separately, it's easiest to redirect  them\nseparately to files, and then read from those files when the program is done:\n\nsystem(\"program args 1>program.stdout 2>program.stderr\");\n\nThe STDIN filehandle used by the command is inherited from Perl's STDIN.  For example:\n\nopen(SPLAT, \"stuff\")   || die \"can't open stuff: $!\";\nopen(STDIN, \"<&SPLAT\") || die \"can't dupe SPLAT: $!\";\nprint STDOUT `sort`;\n\nwill print the sorted contents of the file named \"stuff\".\n\nUsing  single-quote  as  a  delimiter  protects  the  command  from  Perl's  double-quote\ninterpolation, passing it on to the shell instead:\n\n$perlinfo  = qx(ps $$);            # that's Perl's $$\n$shellinfo = qx'ps $$';            # that's the new shell's $$\n\nHow that string gets evaluated is entirely subject to the  command  interpreter  on  your\nsystem.   On  most  platforms,  you will have to protect shell metacharacters if you want\nthem treated literally.  This is in practice difficult to do,  as  it's  unclear  how  to\nescape which characters.  See perlsec for a clean and safe example of a manual fork() and\nexec() to emulate backticks safely.\n\nOn  some  platforms (notably DOS-like ones), the shell may not be capable of dealing with\nmultiline commands, so putting newlines in the string may not get you what you want.  You\nmay be able to evaluate multiple commands in a single line by separating  them  with  the\ncommand  separator  character, if your shell supports that (for example, \";\" on many Unix\nshells and \"&\" on the Windows NT \"cmd\" shell).\n\nPerl will attempt to flush all files opened for output before starting the child process,\nbut this may not be supported on some platforms (see perlport).  To be safe, you may need\nto set $| ($AUTOFLUSH in \"English\") or call the autoflush() method of \"IO::Handle\" on any\nopen handles.\n\nBeware that some command shells may place restrictions on the length of the command line.\nYou must ensure your strings don't exceed this limit after any necessary  interpolations.\nSee   the  platform-specific  release  notes  for  more  details  about  your  particular\nenvironment.\n\nUsing this operator can lead to programs that are difficult to port,  because  the  shell\ncommands  called  vary  between  systems,  and may in fact not be present at all.  As one\nexample, the \"type\" command under the POSIX shell  is  very  different  from  the  \"type\"\ncommand  under  DOS.   That doesn't mean you should go out of your way to avoid backticks\nwhen they're the right way to get something done.  Perl was made to be a  glue  language,\nand one of the things it glues together is commands.  Just understand what you're getting\nyourself into.\n\nLike  \"system\",  backticks  put  the  child  process  exit  code in $?.  If you'd like to\nmanually inspect failure, you can check all possible failure modes by inspecting $?  like\nthis:\n\nif ($? == -1) {\nprint \"failed to execute: $!\\n\";\n}\nelsif ($? & 127) {\nprintf \"child died with signal %d, %s coredump\\n\",\n($? & 127),  ($? & 128) ? 'with' : 'without';\n}\nelse {\nprintf \"child exited with value %d\\n\", $? >> 8;\n}\n\nUse  the  open  pragma  to  control  the  I/O  layers used when reading the output of the\ncommand, for example:\n\nuse open IN => \":encoding(UTF-8)\";\nmy $x = `cmd-producing-utf-8`;\n\n\"qx//\" can also be called like a function with \"readpipe\" in perlfunc.\n\nSee \"I/O Operators\" for more discussion.\n\n\"qw/STRING/\"\nEvaluates to a list of the words extracted out of STRING, using  embedded  whitespace  as\nthe word delimiters.  It can be understood as being roughly equivalent to:\n\nsplit(\" \", q/STRING/);\n\nthe  differences  being that it only splits on ASCII whitespace, generates a real list at\ncompile time, and in scalar context it returns the last element in  the  list.   So  this\nexpression:\n\nqw(foo bar baz)\n\nis semantically equivalent to the list:\n\n\"foo\", \"bar\", \"baz\"\n\nSome frequently seen examples:\n\nuse POSIX qw( setlocale localeconv )\n@EXPORT = qw( foo bar baz );\n\nA  common  mistake  is to try to separate the words with commas or to put comments into a\nmulti-line \"qw\"-string.  For this reason, the \"use warnings\" pragma  and  the  -w  switch\n(that  is,  the $^W variable) produces warnings if the STRING contains the \",\" or the \"#\"\ncharacter.\n\n\"tr/SEARCHLIST/REPLACEMENTLIST/cdsr\"\n\"y/SEARCHLIST/REPLACEMENTLIST/cdsr\"\nTransliterates all occurrences of the characters found (or not found if the \"/c\" modifier\nis specified) in the search list with the positionally  corresponding  character  in  the\nreplacement  list,  possibly  deleting  some,  depending  on the modifiers specified.  It\nreturns the number of characters replaced or deleted.  If no string is specified via  the\n\"=~\" or \"!~\" operator, the $ string is transliterated.\n\nFor sed devotees, \"y\" is provided as a synonym for \"tr\".\n\nIf the \"/r\" (non-destructive) option is present, a new copy of the string is made and its\ncharacters transliterated, and this copy is returned no matter whether it was modified or\nnot:  the  original  string  is  always  left  unchanged.  The new copy is always a plain\nstring, even if the input string is an object or a tied variable.\n\nUnless the \"/r\" option is used, the string specified with \"=~\" must be a scalar variable,\nan array element, a hash element, or an assignment to one of those; in  other  words,  an\nlvalue.\n\nThe characters delimitting SEARCHLIST and REPLACEMENTLIST can be any printable character,\nnot  just forward slashes.  If they are single quotes (\"tr'SEARCHLIST'REPLACEMENTLIST'\"),\nthe only interpolation is removal of \"\\\" from pairs of \"\\\\\"; so hyphens  are  interpreted\nliterally rather than specifying a character range.\n\nOtherwise,  a  character  range may be specified with a hyphen, so \"tr/A-J/0-9/\" does the\nsame replacement as \"tr/ACEGIBDFHJ/0246813579/\".\n\nIf the SEARCHLIST is delimited by bracketing quotes, the REPLACEMENTLIST  must  have  its\nown   pair  of  quotes,  which  may  or  may  not  be  bracketing  quotes;  for  example,\n\"tr(aeiouy)(yuoiea)\" or \"tr[+\\-*/]\"ABCD\"\".  This final example shows a  way  to  visually\nclarify  what  is  going  on  for  people  who  are more familiar with regular expression\npatterns than with \"tr\", and who may think forward slash delimiters imply  that  \"tr\"  is\nmore  like a regular expression pattern than it actually is.  (Another option might be to\nuse \"tr[...][...]\".)\n\n\"tr\" isn't fully like bracketed character classes, just (significantly)  more  like  them\nthan  it is to full patterns.  For example, characters appearing more than once in either\nlist behave differently here than in patterns, and \"tr\" lists do  not  allow  backslashed\ncharacter  classes  such as \"\\d\" or \"\\pL\", nor variable interpolation, so \"$\" and \"@\" are\nalways treated as literals.\n\nThe allowed elements are literals plus \"\\'\" (meaning a single quote).  If the  delimiters\naren't  single  quotes,  also allowed are any of the escape sequences accepted in double-\nquoted strings.  Escape sequence details are in the table  near  the  beginning  of  this\nsection.\n\nA  hyphen at the beginning or end, or preceded by a backslash is also always considered a\nliteral.  Precede a delimiter character with a backslash to allow it.\n\nThe \"tr\" operator is not equivalent to the tr(1) utility.  \"tr[a-z][A-Z]\" will  uppercase\nthe  26  letters  \"a\" through \"z\", but for case changing not confined to ASCII, use \"lc\",\n\"uc\", \"lcfirst\", \"ucfirst\" (all documented in perlfunc),  or  the  substitution  operator\n\"s/PATTERN/REPLACEMENT/\" (with \"\\U\", \"\\u\", \"\\L\", and \"\\l\" string-interpolation escapes in\nthe REPLACEMENT portion).\n\nMost  ranges  are  unportable  between character sets, but certain ones signal Perl to do\nspecial handling to make them portable.  There are two classes of portable  ranges.   The\nfirst  are  any  subsets of the ranges \"A-Z\", \"a-z\", and \"0-9\", when expressed as literal\ncharacters.\n\ntr/h-k/H-K/\n\ncapitalizes the letters \"h\", \"i\", \"j\", and \"k\" and  nothing  else,  no  matter  what  the\nplatform's character set is.  In contrast, all of\n\ntr/\\x68-\\x6B/\\x48-\\x4B/\ntr/h-\\x6B/H-\\x4B/\ntr/\\x68-k/\\x48-K/\n\ndo  the  same  capitalizations  as  the previous example when run on ASCII platforms, but\nsomething completely different on EBCDIC ones.\n\nThe second class of portable ranges is invoked when one or both of the range's end points\nare expressed as \"\\N{...}\"\n\n$string =~ tr/\\N{U+20}-\\N{U+7E}//d;\n\nremoves from $string all the platform's characters which are equivalent to any of Unicode\nU+0020, U+0021, ... U+007D, U+007E.  This is a portable range, and has the same effect on\nevery platform it is run on.  In this example, these are the ASCII printable  characters.\nSo  after  this  is  run,  $string  has  only controls and characters which have no ASCII\nequivalents.\n\nBut, even for portable ranges, it is not  generally  obvious  what  is  included  without\nhaving  to  look  things  up in the manual.  A sound principle is to use only ranges that\nboth begin from, and end at, either ASCII alphabetics of equal case  (\"b-e\",  \"B-E\"),  or\ndigits  (\"1-4\").  Anything else is unclear (and unportable unless \"\\N{...}\" is used).  If\nin doubt, spell out the character sets in full.\n\nOptions:\n\nc   Complement the SEARCHLIST.\nd   Delete found but unreplaced characters.\nr   Return the modified string and leave the original string\nuntouched.\ns   Squash duplicate replaced characters.\n\nIf the \"/d\" modifier is specified, any characters specified by SEARCHLIST  not  found  in\nREPLACEMENTLIST are deleted.  (Note that this is slightly more flexible than the behavior\nof some tr programs, which delete anything they find in the SEARCHLIST, period.)\n\nIf  the  \"/s\"  modifier  is  specified,  sequences of characters, all in a row, that were\ntransliterated to the same character are squashed down  to  a  single  instance  of  that\ncharacter.\n\nmy $a = \"aaabbbca\";\n$a =~ tr/ab/dd/s;     # $a now is \"dcd\"\n\nIf  the  \"/d\"  modifier  is  used,  the  REPLACEMENTLIST is always interpreted exactly as\nspecified.  Otherwise, if the REPLACEMENTLIST is shorter than the SEARCHLIST,  the  final\ncharacter,  if  any,  is  replicated  until  it  is  long enough.  There won't be a final\ncharacter if and only if the REPLACEMENTLIST is empty, in which case  REPLACEMENTLIST  is\ncopied  from SEARCHLIST.    An empty REPLACEMENTLIST is useful for counting characters in\na class, or for squashing character sequences in a class.\n\ntr/abcd//            tr/abcd/abcd/\ntr/abcd/AB/          tr/abcd/ABBB/\ntr/abcd//d           s/[abcd]//g\ntr/abcd/AB/d         (tr/ab/AB/ + s/[cd]//g)  - but run together\n\nIf the \"/c\" modifier is specified, the characters to be transliterated are the  ones  NOT\nin SEARCHLIST, that is, it is complemented.  If \"/d\" and/or \"/s\" are also specified, they\napply  to  the complemented SEARCHLIST.  Recall, that if REPLACEMENTLIST is empty (except\nunder \"/d\") a copy of SEARCHLIST is used instead.  That copy is made after  complementing\nunder  \"/c\".   SEARCHLIST  is  sorted  by  code  point order after complementing, and any\nREPLACEMENTLIST  is applied to that sorted result.  This means that under \"/c\", the order\nof the characters specified in SEARCHLIST is irrelevant.   This  can  lead  to  different\nresults  on  EBCDIC systems if REPLACEMENTLIST contains more than one character, hence it\nis generally non-portable to use \"/c\" with such a REPLACEMENTLIST.\n\nAnother way of describing the operation is this: If \"/c\" is specified, the SEARCHLIST  is\nsorted  by  code point order, then complemented.  If REPLACEMENTLIST is empty and \"/d\" is\nnot specified, REPLACEMENTLIST is replaced by a copy of  SEARCHLIST  (as  modified  under\n\"/c\"),  and these potentially modified lists are used as the basis for what follows.  Any\ncharacter in the target string that isn't in  SEARCHLIST  is  passed  through  unchanged.\nEvery   other   character   in  the  target  string  is  replaced  by  the  character  in\nREPLACEMENTLIST that positionally corresponds to its  mate  in  SEARCHLIST,  except  that\nunder \"/s\", the 2nd and following characters are squeezed out in a sequence of characters\nin  a  row  that  all  translate  to  the  same  character.  If SEARCHLIST is longer than\nREPLACEMENTLIST, characters in the target string that match  a  character  in  SEARCHLIST\nthat  doesn't have a correspondence in REPLACEMENTLIST are either deleted from the target\nstring if \"/d\" is specified; or replaced by the final  character  in  REPLACEMENTLIST  if\n\"/d\" isn't specified.\n\nSome examples:\n\n$ARGV[1] =~ tr/A-Z/a-z/;   # canonicalize to lower case ASCII\n\n$cnt = tr/*/*/;            # count the stars in $\n$cnt = tr/*//;             # same thing\n\n$cnt = $sky =~ tr/*/*/;    # count the stars in $sky\n$cnt = $sky =~ tr/*//;     # same thing\n\n$cnt = $sky =~ tr/*//c;    # count all the non-stars in $sky\n$cnt = $sky =~ tr/*/*/c;   # same, but transliterate each non-star\n# into a star, leaving the already-stars\n# alone.  Afterwards, everything in $sky\n# is a star.\n\n$cnt = tr/0-9//;           # count the ASCII digits in $\n\ntr/a-zA-Z//s;              # bookkeeper -> bokeper\ntr/o/o/s;                  # bookkeeper -> bokkeeper\ntr/oe/oe/s;                # bookkeeper -> bokkeper\ntr/oe//s;                  # bookkeeper -> bokkeper\ntr/oe/o/s;                 # bookkeeper -> bokkopor\n\n($HOST = $host) =~ tr/a-z/A-Z/;\n$HOST = $host  =~ tr/a-z/A-Z/r; # same thing\n\n$HOST = $host =~ tr/a-z/A-Z/r   # chained with s///r\n=~ s/:/ -p/r;\n\ntr/a-zA-Z/ /cs;                 # change non-alphas to single space\n\n@stripped = map tr/a-zA-Z/ /csr, @original;\n# /r with map\n\ntr [\\200-\\377]\n[\\000-\\177];                 # wickedly delete 8th bit\n\n$foo !~ tr/A/a/    # transliterate all the A's in $foo to 'a',\n# return 0 if any were found and changed.\n# Otherwise return 1\n\nIf multiple transliterations are given for a character, only the first one is used:\n\ntr/AAA/XYZ/\n\nwill transliterate any A to X.\n\nBecause  the  transliteration  table is built at compile time, neither the SEARCHLIST nor\nthe REPLACEMENTLIST are subjected to double quote interpolation.  That means that if  you\nwant to use variables, you must use an eval():\n\neval \"tr/$oldlist/$newlist/\";\ndie $@ if $@;\n\neval \"tr/$oldlist/$newlist/, 1\" or die $@;\n\n\"<<EOF\"\nA  line-oriented form of quoting is based on the shell \"here-document\" syntax.  Following\na \"<<\" you specify a string to terminate the quoted material, and all lines following the\ncurrent line down to the terminating string are the value of the item.\n\nPrefixing the terminating string with a \"~\" specifies that  you  want  to  use  \"Indented\nHere-docs\" (see below).\n\nThe  terminating  string  may  be either an identifier (a word), or some quoted text.  An\nunquoted identifier works like double quotes.  There may not be a space between the  \"<<\"\nand  the  identifier, unless the identifier is explicitly quoted.  The terminating string\nmust appear by itself (unquoted and with no surrounding whitespace)  on  the  terminating\nline.\n\nIf  the  terminating string is quoted, the type of quotes used determine the treatment of\nthe text.\n\nDouble Quotes\nDouble quotes indicate that the text will be  interpolated  using  exactly  the  same\nrules as normal double quoted strings.\n\nprint <<EOF;\nThe price is $Price.\nEOF\n\nprint << \"EOF\"; # same as above\nThe price is $Price.\nEOF\n\nSingle Quotes\nSingle  quotes  indicate the text is to be treated literally with no interpolation of\nits content.  This is similar to single quoted strings except that  backslashes  have\nno  special  meaning,  with \"\\\\\" being treated as two backslashes and not one as they\nwould in every other quoting construct.\n\nJust as in the shell, a backslashed bareword following the \"<<\" means the same  thing\nas a single-quoted string does:\n\n$cost = <<'VISTA';  # hasta la ...\nThat'll be $10 please, ma'am.\nVISTA\n\n$cost = <<\\VISTA;   # Same thing!\nThat'll be $10 please, ma'am.\nVISTA\n\nThis  is  the  only  form  of  quoting  in perl where there is no need to worry about\nescaping content, something that code generators can and do make good use of.\n\nBackticks\nThe content of the here doc is treated just  as  it  would  be  if  the  string  were\nembedded  in  backticks.   Thus  the content is interpolated as though it were double\nquoted and then executed via the shell, with the results of the execution returned.\n\nprint << `EOC`; # execute command and get results\necho hi there\nEOC\n\nIndented Here-docs\nThe here-doc modifier \"~\" allows you to indent your here-docs to make the  code  more\nreadable:\n\nif ($somevar) {\nprint <<~EOF;\nThis is a here-doc\nEOF\n}\n\nThis will print...\n\nThis is a here-doc\n\n...with no leading whitespace.\n\nThe  line  containing the delimiter that marks the end of the here-doc determines the\nindentation template for the whole thing.  Compilation croaks if any  non-empty  line\ninside  the  here-doc  does not begin with the precise indentation of the terminating\nline.  (An empty line consists of the single character \"\\n\".)  For  example,  suppose\nthe  terminating  line  begins  with  a tab character followed by 4 space characters.\nEvery non-empty line in the here-doc must begin with a  tab  followed  by  4  spaces.\nThey  are  stripped  from  each line, and any leading white space remaining on a line\nserves as the  indentation  for  that  line.   Currently,  only  the  TAB  and  SPACE\ncharacters are treated as whitespace for this purpose.  Tabs and spaces may be mixed,\nbut are matched exactly; tabs remain tabs and are not expanded.\n\nAdditional  beginning  whitespace  (beyond  what  preceded  the  delimiter)  will  be\npreserved:\n\nprint <<~EOF;\nThis text is not indented\nThis text is indented with two spaces\nThis text is indented with two tabs\nEOF\n\nFinally, the modifier may be used with all of the forms mentioned above:\n\n<<~\\EOF;\n<<~'EOF'\n<<~\"EOF\"\n<<~`EOF`\n\nAnd whitespace may be used between the \"~\" and quoted delimiters:\n\n<<~ 'EOF'; # ... \"EOF\", `EOF`\n\nIt is possible to stack multiple here-docs in a row:\n\nprint <<\"foo\", <<\"bar\"; # you can stack them\nI said foo.\nfoo\nI said bar.\nbar\n\nmyfunc(<< \"THIS\", 23, <<'THAT');\nHere's a line\nor two.\nTHIS\nand here's another.\nTHAT\n\nJust don't forget that you have to put a semicolon on the end to finish the statement, as\nPerl doesn't know you're not going to try to do this:\n\nprint <<ABC\n179231\nABC\n+ 20;\n\nIf you want to remove the line terminator from your here-docs, use chomp().\n\nchomp($string = <<'END');\nThis is a string.\nEND\n\nIf you want your here-docs to be indented with the rest of the  code,  use  the  \"<<~FOO\"\nconstruct described under \"Indented Here-docs\":\n\n$quote = <<~'FINIS';\nThe Road goes ever on and on,\ndown from the door where it began.\nFINIS\n\nIf  you  use  a  here-doc  within  a delimited construct, such as in \"s///eg\", the quoted\nmaterial must still come on the line following the \"<<FOO\" marker, which means it may  be\ninside the delimited construct:\n\ns/this/<<E . 'that'\nthe other\nE\n. 'more '/eg;\n\nIt works this way as of Perl 5.18.  Historically, it was inconsistent, and you would have\nto write\n\ns/this/<<E . 'that'\n. 'more '/eg;\nthe other\nE\n\noutside of string evals.\n\nAdditionally,  quoting  rules  for  the  end-of-string identifier are unrelated to Perl's\nquoting rules.  q(), qq(), and the like are not supported in place of '' and \"\", and  the\nonly interpolation is for backslashing the quoting character:\n\nprint << \"abc\\\"def\";\ntesting...\nabc\"def\n\nFinally,  quoted  strings  cannot  span  multiple  lines.   The  general rule is that the\nidentifier must be a string literal.  Stick with that, and you should be safe.\n"
                },
                {
                    "name": "Gory details of parsing quoted constructs",
                    "content": "When presented with something that might have several different  interpretations,  Perl  uses\nthe  DWIM (that's \"Do What I Mean\") principle to pick the most probable interpretation.  This\nstrategy is so successful that Perl programmers often do not suspect the ambivalence of  what\nthey  write.  But from time to time, Perl's notions differ substantially from what the author\nhonestly meant.\n\nThis section hopes to clarify how Perl handles quoted constructs.  Although the  most  common\nreason  to  learn  this  is  to unravel labyrinthine regular expressions, because the initial\nsteps of parsing are the same for all quoting operators, they are all discussed together.\n\nThe most important Perl parsing rule is the first one  discussed  below:  when  processing  a\nquoted  construct,  Perl first finds the end of that construct, then interprets its contents.\nIf you understand this rule, you may skip the rest of this section on the first reading.  The\nother rules are likely to contradict the user's expectations much less frequently  than  this\nfirst one.\n\nSome  passes  discussed  below  are performed concurrently, but because their results are the\nsame, we consider  them  individually.   For  different  quoting  constructs,  Perl  performs\ndifferent  numbers  of passes, from one to four, but these passes are always performed in the\nsame order.\n\nFinding the end\nThe first pass is finding the end of the quoted construct.  This results in saving  to  a\nsafe location a copy of the text (between the starting and ending delimiters), normalized\nas necessary to avoid needing to know what the original delimiters were.\n\nIf  the  construct  is  a here-doc, the ending delimiter is a line that has a terminating\nstring as the content.  Therefore \"<<EOF\" is terminated by \"EOF\" immediately followed  by\n\"\\n\"  and starting from the first column of the terminating line.  When searching for the\nterminating line of a here-doc, nothing is skipped.  In  other  words,  lines  after  the\nhere-doc syntax are compared with the terminating string line by line.\n\nFor  the  constructs  except here-docs, single characters are used as starting and ending\ndelimiters.  If the starting delimiter is an opening punctuation (that is \"(\", \"[\",  \"{\",\nor \"<\"), the ending delimiter is the corresponding closing punctuation (that is \")\", \"]\",\n\"}\",  or  \">\").  If the starting delimiter is an unpaired character like \"/\" or a closing\npunctuation, the ending delimiter is the same as the starting delimiter.  Therefore a \"/\"\nterminates a \"qq//\" construct, while a \"]\" terminates both \"qq[]\" and \"qq]]\" constructs.\n\nWhen searching for single-character delimiters, escaped delimiters and \"\\\\\" are  skipped.\nFor  example,  while  searching  for  terminating  \"/\", combinations of \"\\\\\" and \"\\/\" are\nskipped.  If the delimiters are bracketing, nested pairs are also skipped.  For  example,\nwhile  searching  for  a  closing  \"]\" paired with the opening \"[\", combinations of \"\\\\\",\n\"\\]\", and \"\\[\" are all skipped, and nested \"[\" and \"]\" are  skipped  as  well.   However,\nwhen  backslashes  are  used  as  the  delimiters  (like  \"qq\\\\\" and \"tr\\\\\\\"), nothing is\nskipped.  During the search for the end, backslashes  that  escape  delimiters  or  other\nbackslashes are removed (exactly speaking, they are not copied to the safe location).\n\nFor  constructs  with  three-part delimiters (\"s///\", \"y///\", and \"tr///\"), the search is\nrepeated once more.  If the first delimiter is not  an  opening  punctuation,  the  three\ndelimiters  must  be  the  same,  such  as  \"s!!!\"  and \"tr)))\", in which case the second\ndelimiter terminates the left part and starts the right part at once.  If the  left  part\nis  delimited  by  bracketing  punctuation (that is \"()\", \"[]\", \"{}\", or \"<>\"), the right\npart needs another pair of delimiters such as \"s(){}\"  and  \"tr[]//\".   In  these  cases,\nwhitespace  and  comments  are  allowed  between the two parts, although the comment must\nfollow at least one whitespace character; otherwise a character expected as the start  of\nthe comment may be regarded as the starting delimiter of the right part.\n\nDuring this search no attention is paid to the semantics of the construct.  Thus:\n\n\"$hash{\"$foo/$bar\"}\"\n\nor:\n\nm/\nbar       # NOT a comment, this slash / terminated m//!\n/x\n\ndo  not  form  legal quoted expressions.   The quoted part ends on the first \"\"\" and \"/\",\nand the rest happens to be a syntax error.  Because the slash that terminated  \"m//\"  was\nfollowed  by  a  \"SPACE\",  the example above is not \"m//x\", but rather \"m//\" with no \"/x\"\nmodifier.  So the embedded \"#\" is interpreted as a literal \"#\".\n\nAlso no attention is paid to \"\\c\\\" (multichar control char syntax)  during  this  search.\nThus  the second \"\\\" in \"qq/\\c\\/\" is interpreted as a part of \"\\/\", and the following \"/\"\nis not recognized as a delimiter.  Instead, use \"\\034\" or \"\\x1c\" at  the  end  of  quoted\nconstructs.\n\nInterpolation\nThe  next step is interpolation in the text obtained, which is now delimiter-independent.\nThere are multiple cases.\n\n\"<<'EOF'\"\nNo interpolation is performed.  Note that the combination \"\\\\\" is left intact,  since\nescaped delimiters are not available for here-docs.\n\n\"m''\", the pattern of \"s'''\"\nNo  interpolation  is  performed  at this stage.  Any backslashed sequences including\n\"\\\\\" are treated at the stage of \"Parsing regular expressions\".\n\n'', \"q//\", \"tr'''\", \"y'''\", the replacement of \"s'''\"\nThe only interpolation is removal of \"\\\"  from  pairs  of  \"\\\\\".   Therefore  \"-\"  in\n\"tr'''\"  and  \"y'''\"  is  treated  literally  as  a  hyphen and no character range is\navailable.  \"\\1\" in the replacement of \"s'''\" does not work as $1.\n\n\"tr///\", \"y///\"\nNo variable interpolation occurs.  String modifying combinations for case and quoting\nsuch as \"\\Q\", \"\\U\", and \"\\E\" are not recognized.  The other escape sequences such  as\n\"\\200\"  and  \"\\t\"  and  backslashed characters such as \"\\\\\" and \"\\-\" are converted to\nappropriate literals.  The character \"-\" is treated specially and therefore  \"\\-\"  is\ntreated as a literal \"-\".\n\n\"\", ``, \"qq//\", \"qx//\", \"<file*glob>\", \"<<\"EOF\"\"\n\"\\Q\",  \"\\U\",  \"\\u\",  \"\\L\",  \"\\l\",  \"\\F\"  (possibly paired with \"\\E\") are converted to\ncorresponding   Perl   constructs.    Thus,   \"$foo\\Qbaz$bar\"   is    converted    to\n\"$foo . (quotemeta(\"baz\" . $bar))\"  internally.   The  other escape sequences such as\n\"\\200\" and \"\\t\" and backslashed characters such as \"\\\\\" and \"\\-\"  are  replaced  with\nappropriate expansions.\n\nLet  it  be stressed that whatever falls between \"\\Q\" and \"\\E\" is interpolated in the\nusual way.  Something like \"\\Q\\\\E\" has no \"\\E\" inside.  Instead, it has  \"\\Q\",  \"\\\\\",\nand  \"E\",  so  the result is the same as for \"\\\\\\\\E\".  As a general rule, backslashes\nbetween \"\\Q\" and  \"\\E\"  may  lead  to  counterintuitive  results.   So,  \"\\Q\\t\\E\"  is\nconverted  to  quotemeta(\"\\t\"),  which  is  the  same  as  \"\\\\\\t\"  (since  TAB is not\nalphanumeric).  Note also that:\n\n$str = '\\t';\nreturn \"\\Q$str\";\n\nmay be closer to the conjectural intention of the writer of \"\\Q\\t\\E\".\n\nInterpolated scalars and arrays are  converted  internally  to  the  \"join\"  and  \".\"\ncatenation operations.  Thus, \"$foo XXX '@arr'\" becomes:\n\n$foo . \" XXX '\" . (join $\", @arr) . \"'\";\n\nAll operations above are performed simultaneously, left to right.\n\nBecause  the  result of \"\\Q STRING \\E\" has all metacharacters quoted, there is no way\nto insert a literal \"$\" or \"@\" inside a \"\\Q\\E\" pair.  If protected by \"\\\",  \"$\"  will\nbe quoted to become \"\\\\\\$\"; if not, it is interpreted as the start of an interpolated\nscalar.\n\nNote  also  that  the  interpolation  code  needs  to  make  a  decision on where the\ninterpolated scalar ends.  For instance, whether \"a $x -> {c}\" really means:\n\n\"a \" . $x . \" -> {c}\";\n\nor:\n\n\"a \" . $x -> {c};\n\nMost of the time, the longest possible text that  does  not  include  spaces  between\ncomponents  and  which contains matching braces or brackets.  because the outcome may\nbe determined by voting based on heuristic estimators, the  result  is  not  strictly\npredictable.  Fortunately, it's usually correct for ambiguous cases.\n\nThe replacement of \"s///\"\nProcessing  of  \"\\Q\",  \"\\U\", \"\\u\", \"\\L\", \"\\l\", \"\\F\" and interpolation happens as with\n\"qq//\" constructs.\n\nIt is at this step that \"\\1\" is begrudgingly converted to $1 in the replacement  text\nof \"s///\", in order to correct the incorrigible sed hackers who haven't picked up the\nsaner  idiom  yet.   A  warning  is  emitted  if  the \"use warnings\" pragma or the -w\ncommand-line flag (that is, the $^W variable) was set.\n\n\"RE\" in \"m?RE?\", \"/RE/\", \"m/RE/\", \"s/RE/foo/\",\nProcessing of \"\\Q\", \"\\U\", \"\\u\", \"\\L\", \"\\l\", \"\\F\",  \"\\E\",  and  interpolation  happens\n(almost) as with \"qq//\" constructs.\n\nProcessing of \"\\N{...}\" is also done here, and compiled into an intermediate form for\nthe  regex compiler.  (This is because, as mentioned below, the regex compilation may\nbe done at execution time, and \"\\N{...}\" is a compile-time construct.)\n\nHowever any other combinations of \"\\\" followed by a character are not substituted but\nonly skipped, in order to parse them as regular expressions at  the  following  step.\nAs  \"\\c\"  is skipped at this step, \"@\" of \"\\c@\" in RE is possibly treated as an array\nsymbol (for example @foo), even though the same text in \"qq//\" gives interpolation of\n\"\\c@\".\n\nCode blocks such as \"(?{BLOCK})\" are handled by temporarily passing control  back  to\nthe  perl  parser,  in  a similar way that an interpolated array subscript expression\nsuch as \"foo$array[1+f(\"[xyz\")]bar\" would be.\n\nMoreover, inside \"(?{BLOCK})\", \"(?# comment )\", and a \"#\"-comment in  a  \"/x\"-regular\nexpression,  no  processing is performed whatsoever.  This is the first step at which\nthe presence of the \"/x\" modifier is relevant.\n\nInterpolation in patterns has several quirks: $|, $(,  $),  \"@+\"  and  \"@-\"  are  not\ninterpolated,   and  constructs  $var[SOMETHING]  are  voted  (by  several  different\nestimators) to be either an array element or $var  followed  by  an  RE  alternative.\nThis is where the notation \"${arr[$bar]}\" comes handy: \"/${arr[0-9]}/\" is interpreted\nas array element -9, not as a regular expression from the variable $arr followed by a\ndigit,  which  would  be  the  interpretation  of  \"/$arr[0-9]/\".  Since voting among\ndifferent estimators may occur, the result is not predictable.\n\nThe lack of processing of \"\\\\\" creates specific restrictions  on  the  post-processed\ntext.   If  the delimiter is \"/\", one cannot get the combination \"\\/\" into the result\nof this step.  \"/\" will finish the regular expression, \"\\/\" will be stripped  to  \"/\"\non  the  previous  step,  and \"\\\\/\" will be left as is.  Because \"/\" is equivalent to\n\"\\/\" inside a regular expression, this does not matter unless the  delimiter  happens\nto  be  character  special  to  the  RE engine, such as in \"s*foo*bar*\", \"m[foo]\", or\n\"m?foo?\"; or an alphanumeric char, as in:\n\nm m ^ a \\s* b mmx;\n\nIn the RE above, which is intentionally obfuscated for illustration, the delimiter is\n\"m\", the modifier is \"mx\", and after delimiter-removal the RE  is  the  same  as  for\n\"m/ ^ a \\s* b /mx\".   There's more than one reason you're encouraged to restrict your\ndelimiters to non-alphanumeric, non-whitespace choices.\n\nThis step is the last one for  all  constructs  except  regular  expressions,  which  are\nprocessed further.\n\nParsing regular expressions\nPrevious  steps  were performed during the compilation of Perl code, but this one happens\nat run time,  although  it  may  be  optimized  to  be  calculated  at  compile  time  if\nappropriate.   After  preprocessing  described  above,  and  possibly after evaluation if\nconcatenation, joining, casing translation, or metaquoting are  involved,  the  resulting\nstring is passed to the RE engine for compilation.\n\nWhatever  happens  in the RE engine might be better discussed in perlre, but for the sake\nof continuity, we shall do so here.\n\nThis is another step where the presence of the \"/x\" modifier is relevant.  The RE  engine\nscans the string from left to right and converts it into a finite automaton.\n\nBackslashed  characters  are  either replaced with corresponding literal strings (as with\n\"\\{\"), or else they generate special nodes  in  the  finite  automaton  (as  with  \"\\b\").\nCharacters  special to the RE engine (such as \"|\") generate corresponding nodes or groups\nof nodes.  \"(?#...)\" comments are ignored.  All the rest is either converted  to  literal\nstrings  to match, or else is ignored (as is whitespace and \"#\"-style comments if \"/x\" is\npresent).\n\nParsing of the bracketed character class construct, \"[...]\", is rather different than the\nrule used for the rest of the pattern.  The terminator of this construct is  found  using\nthe  same  rules  as  for  finding the terminator of a \"{}\"-delimited construct, the only\nexception being that \"]\" immediately following \"[\" is treated as  though  preceded  by  a\nbackslash.\n\nThe  terminator  of  runtime  \"(?{...})\" is found by temporarily switching control to the\nperl parser, which should stop at the point where the logically balancing terminating \"}\"\nis found.\n\nIt is possible to inspect both the string given to RE engine  and  the  resulting  finite\nautomaton.   See  the  arguments  \"debug\"/\"debugcolor\" in the \"use re\" pragma, as well as\nPerl's -Dr command-line switch documented in \"Command Switches\" in perlrun.\n\nOptimization of regular expressions\nThis step is listed for completeness only.  Since it does not change  semantics,  details\nof  this  step are not documented and are subject to change without notice.  This step is\nperformed over the finite automaton that was generated during the previous pass.\n\nIt is at this stage that split() silently optimizes \"/^/\" to mean \"/^/m\".\n"
                },
                {
                    "name": "I/O Operators",
                    "content": "There are several I/O operators you should know about.\n\nA string enclosed by backticks (grave accents) first  undergoes  double-quote  interpolation.\nIt is then interpreted as an external command, and the output of that command is the value of\nthe  backtick  string, like in a shell.  In scalar context, a single string consisting of all\noutput is returned.  In list context, a list of values is returned, one per line  of  output.\n(You  can  set $/ to use a different line terminator.)  The command is executed each time the\npseudo-literal is evaluated.  The status value of the command is returned in $? (see  perlvar\nfor  the  interpretation  of  $?).   Unlike  in  csh,  no  translation  is done on the return\ndata--newlines remain newlines.  Unlike in any of the  shells,  single  quotes  do  not  hide\nvariable  names in the command from interpretation.  To pass a literal dollar-sign through to\nthe shell you need to hide it with a backslash.  The generalized form of backticks is \"qx//\",\nor you can call the \"readpipe\" in perlfunc function.  (Because backticks always undergo shell\nexpansion as well, see perlsec for security concerns.)\n\nIn scalar context, evaluating a filehandle in angle brackets yields the next line  from  that\nfile  (the newline, if any, included), or \"undef\" at end-of-file or on error.  When $/ is set\nto \"undef\" (sometimes known as file-slurp mode) and the file is  empty,  it  returns  ''  the\nfirst time, followed by \"undef\" subsequently.\n\nOrdinarily you must assign the returned value to a variable, but there is one situation where\nan  automatic  assignment  happens.  If and only if the input symbol is the only thing inside\nthe conditional of a \"while\" statement (even if disguised as a for(;;) loop),  the  value  is\nautomatically  assigned  to the global variable $, destroying whatever was there previously.\n(This may seem like an odd thing to you, but you'll use the construct in  almost  every  Perl\nscript  you  write.)   The  $  variable  is  not implicitly localized.  You'll have to put a\n\"local $;\" before the loop if you want that to happen.  Furthermore, if the input symbol  or\nan  explicit assignment of the input symbol to a scalar is used as a \"while\"/\"for\" condition,\nthen the condition actually tests for definedness of the  expression's  value,  not  for  its\nregular truth value.\n\nThus the following lines are equivalent:\n\nwhile (defined($ = <STDIN>)) { print; }\nwhile ($ = <STDIN>) { print; }\nwhile (<STDIN>) { print; }\nfor (;<STDIN>;) { print; }\nprint while defined($ = <STDIN>);\nprint while ($ = <STDIN>);\nprint while <STDIN>;\n\nThis also behaves similarly, but assigns to a lexical variable instead of to $:\n\nwhile (my $line = <STDIN>) { print $line }\n\nIn these loop constructs, the assigned value (whether assignment is automatic or explicit) is\nthen  tested  to  see whether it is defined.  The defined test avoids problems where the line\nhas a string value that would be treated as false by Perl; for example a \"\" or a \"0\" with  no\ntrailing  newline.   If you really mean for such values to terminate the loop, they should be\ntested for explicitly:\n\nwhile (($ = <STDIN>) ne '0') { ... }\nwhile (<STDIN>) { last unless $; ... }\n\nIn other boolean contexts, \"<FILEHANDLE>\" without an explicit \"defined\"  test  or  comparison\nelicits  a  warning  if  the  \"use warnings\"  pragma  or  the -w command-line switch (the $^W\nvariable) is in effect.\n\nThe filehandles  STDIN,  STDOUT,  and  STDERR  are  predefined.   (The  filehandles  \"stdin\",\n\"stdout\",  and \"stderr\" will also work except in packages, where they would be interpreted as\nlocal identifiers rather than global.)  Additional filehandles may be created with the open()\nfunction, amongst others.  See perlopentut and \"open\" in perlfunc for details on this.\n\nIf a \"<FILEHANDLE>\" is used in a context that is looking for a list, a  list  comprising  all\ninput lines is returned, one line per list element.  It's easy to grow to a rather large data\nspace this way, so use with care.\n\n\"<FILEHANDLE>\"  may also be spelled readline(*FILEHANDLE).  See \"readline\" in perlfunc.\n\nThe  null  filehandle \"<>\" (sometimes called the diamond operator) is special: it can be used\nto emulate the behavior of sed and awk, and any other Unix filter program that takes  a  list\nof  filenames,  doing the same to each line of input from all of them.  Input from \"<>\" comes\neither from standard input, or from each file listed on the  command  line.   Here's  how  it\nworks:  the  first  time  \"<>\"  is evaluated, the @ARGV array is checked, and if it is empty,\n$ARGV[0] is set to \"-\", which when opened gives you standard input.  The @ARGV array is  then\nprocessed as a list of filenames.  The loop\n\nwhile (<>) {\n...                     # code for each line\n}\n\nis equivalent to the following Perl-like pseudo code:\n\nunshift(@ARGV, '-') unless @ARGV;\nwhile ($ARGV = shift) {\nopen(ARGV, $ARGV);\nwhile (<ARGV>) {\n...         # code for each line\n}\n}\n\nexcept  that it isn't so cumbersome to say, and will actually work.  It really does shift the\n@ARGV array and put the current filename into the $ARGV variable.  It  also  uses  filehandle\nARGV  internally.   \"<>\"  is just a synonym for \"<ARGV>\", which is magical.  (The pseudo code\nabove doesn't work because it treats \"<ARGV>\" as non-magical.)\n\nSince the null filehandle uses the two argument form of  \"open\"  in  perlfunc  it  interprets\nspecial characters, so if you have a script like this:\n\nwhile (<>) {\nprint;\n}\n\nand  call  it  with  \"perl dangerous.pl 'rm -rfv *|'\", it actually opens a pipe, executes the\n\"rm\" command and reads \"rm\"'s output from that pipe.  If you want all items in  @ARGV  to  be\ninterpreted  as  file  names,  you  can use the module \"ARGV::readonly\" from CPAN, or use the\ndouble diamond bracket:\n\nwhile (<<>>) {\nprint;\n}\n\nUsing double angle brackets inside of a while causes the open to use the three argument  form\n(with  the  second  argument  being  \"<\"),  so all arguments in \"ARGV\" are treated as literal\nfilenames (including \"-\").  (Note that for convenience, if you use \"<<>>\"  and  if  @ARGV  is\nempty, it will still read from the standard input.)\n\nYou  can  modify @ARGV before the first \"<>\" as long as the array ends up containing the list\nof filenames you really want.  Line numbers ($.)  continue as though the input were  one  big\nhappy file.  See the example in \"eof\" in perlfunc for how to reset line numbers on each file.\n\nIf  you  want to set @ARGV to your own list of files, go right ahead.  This sets @ARGV to all\nplain text files if no @ARGV was given:\n\n@ARGV = grep { -f && -T } glob('*') unless @ARGV;\n\nYou can even set them to pipe commands.  For example, this automatically  filters  compressed\narguments through gzip:\n\n@ARGV = map { /\\.(gz|Z)$/ ? \"gzip -dc < $ |\" : $ } @ARGV;\n\nIf  you  want  to pass switches into your script, you can use one of the \"Getopts\" modules or\nput a loop on the front like this:\n\nwhile ($ = $ARGV[0], /^-/) {\nshift;\nlast if /^--$/;\nif (/^-D(.*)/) { $debug = $1 }\nif (/^-v/)     { $verbose++  }\n# ...           # other switches\n}\n\nwhile (<>) {\n# ...           # code for each line\n}\n\nThe \"<>\" symbol will return \"undef\" for end-of-file only once.  If you call  it  again  after\nthis,  it  will  assume  you are processing another @ARGV list, and if you haven't set @ARGV,\nwill read input from STDIN.\n\nIf what the angle brackets contain is a simple scalar variable (for example, $foo), then that\nvariable contains the name of the filehandle to input from, or its typeglob, or  a  reference\nto the same.  For example:\n\n$fh = \\*STDIN;\n$line = <$fh>;\n\nIf  what's  within  the  angle  brackets is neither a filehandle nor a simple scalar variable\ncontaining a filehandle name, typeglob,  or  typeglob  reference,  it  is  interpreted  as  a\nfilename  pattern  to  be globbed, and either a list of filenames or the next filename in the\nlist is returned, depending on context.  This distinction is determined on syntactic  grounds\nalone.   That means \"<$x>\" is always a readline() from an indirect handle, but \"<$hash{key}>\"\nis always a glob().  That's because $x  is  a  simple  scalar  variable,  but  $hash{key}  is\nnot--it's  a  hash element.  Even \"<$x >\" (note the extra space) is treated as \"glob(\"$x \")\",\nnot readline($x).\n\nOne level of double-quote interpretation is done first, but you can't  say  \"<$foo>\"  because\nthat's  an indirect filehandle as explained in the previous paragraph.  (In older versions of\nPerl, programmers would insert curly brackets to force interpretation  as  a  filename  glob:\n\"<${foo}>\".   These  days,  it's considered cleaner to call the internal function directly as\nglob($foo), which is probably the right way to  have  done  it  in  the  first  place.)   For\nexample:\n\nwhile (<*.c>) {\nchmod 0644, $;\n}\n\nis roughly equivalent to:\n\nopen(FOO, \"echo *.c | tr -s ' \\t\\r\\f' '\\\\012\\\\012\\\\012\\\\012'|\");\nwhile (<FOO>) {\nchomp;\nchmod 0644, $;\n}\n\nexcept  that  the  globbing  is  actually  done  internally  using  the standard \"File::Glob\"\nextension.  Of course, the shortest way to do the above is:\n\nchmod 0644, <*.c>;\n\nA (file)glob evaluates its (embedded) argument only when it is  starting  a  new  list.   All\nvalues must be read before it will start over.  In list context, this isn't important because\nyou  automatically  get them all anyway.  However, in scalar context the operator returns the\nnext value each time it's called, or \"undef\" when the list has run out.  As  with  filehandle\nreads,  an  automatic  \"defined\"  is  generated  when  the  glob occurs in the test part of a\n\"while\", because legal glob returns (for example, a file called 0) would otherwise  terminate\nthe  loop.  Again, \"undef\" is returned only once.  So if you're expecting a single value from\na glob, it is much better to say\n\n($file) = <blurch*>;\n\nthan\n\n$file = <blurch*>;\n\nbecause the latter will alternate between returning a filename and returning false.\n\nIf you're trying to do variable interpolation, it's  definitely  better  to  use  the  glob()\nfunction,  because  the  older notation can cause people to become confused with the indirect\nfilehandle notation.\n\n@files = glob(\"$dir/*.[ch]\");\n@files = glob($files[$i]);\n\nIf an angle-bracket-based globbing expression is used as the condition of a \"while\" or  \"for\"\nloop,  then  it  will  be  implicitly  assigned to $.  If either a globbing expression or an\nexplicit assignment of a  globbing  expression  to  a  scalar  is  used  as  a  \"while\"/\"for\"\ncondition,  then  the condition actually tests for definedness of the expression's value, not\nfor its regular truth value.\n"
                },
                {
                    "name": "Constant Folding",
                    "content": "Like C, Perl does a certain amount of expression  evaluation  at  compile  time  whenever  it\ndetermines  that  all  arguments  to  an  operator  are  static and have no side effects.  In\nparticular, string concatenation happens at compile  time  between  literals  that  don't  do\nvariable substitution.  Backslash interpolation also happens at compile time.  You can say\n\n'Now is the time for all'\n. \"\\n\"\n.  'good men to come to.'\n\nand this all reduces to one string internally.  Likewise, if you say\n\nforeach $file (@filenames) {\nif (-s $file > 5 + 100 * 216) {  }\n}\n\nthe  compiler precomputes the number which that expression represents so that the interpreter\nwon't have to.\n"
                },
                {
                    "name": "No-ops",
                    "content": "Perl doesn't officially have a no-op operator, but the bare constants 0 and  1  are  special-\ncased not to produce a warning in void context, so you can for example safely do\n\n1 while foo();\n"
                },
                {
                    "name": "Bitwise String Operators",
                    "content": "Bitstrings of any size may be manipulated by the bitwise operators (\"~ | & ^\").\n\nIf  the  operands  to  a binary bitwise op are strings of different sizes, | and ^ ops act as\nthough the shorter operand had additional zero bits on the right, while  the  &  op  acts  as\nthough  the  longer operand were truncated to the length of the shorter.  The granularity for\nsuch extension or truncation is one or more bytes.\n\n# ASCII-based examples\nprint \"j p \\n\" ^ \" a h\";            # prints \"JAPH\\n\"\nprint \"JA\" | \"  ph\\n\";              # prints \"japh\\n\"\nprint \"japh\\nJunk\" & '';       # prints \"JAPH\\n\";\nprint 'p N$' ^ \" E<H\\n\";            # prints \"Perl\\n\";\n\nIf you are intending to manipulate bitstrings, be certain that you're  supplying  bitstrings:\nIf  an  operand is a number, that will imply a numeric bitwise operation.  You may explicitly\nshow which type of operation you intend by using \"\" or \"0+\", as in the examples below.\n\n$foo =  150  |  105;        # yields 255  (0x96 | 0x69 is 0xFF)\n$foo = '150' |  105;        # yields 255\n$foo =  150  | '105';       # yields 255\n$foo = '150' | '105';       # yields string '155' (under ASCII)\n\n$baz = 0+$foo & 0+$bar;     # both ops explicitly numeric\n$biz = \"$foo\" ^ \"$bar\";     # both ops explicitly stringy\n\nThis somewhat unpredictable behavior can be avoided with the \"bitwise\" feature, new  in  Perl\n5.22.  You can enable it via use feature 'bitwise' or \"use v5.28\".  Before Perl 5.28, it used\nto  emit  a  warning  in  the \"experimental::bitwise\" category.  Under this feature, the four\nstandard bitwise operators (\"~ | & ^\") are always numeric.  Adding a dot after each  operator\n(\"~. |. &. ^.\") forces it to treat its operands as strings:\n\nuse feature \"bitwise\";\n$foo =  150  |  105;        # yields 255  (0x96 | 0x69 is 0xFF)\n$foo = '150' |  105;        # yields 255\n$foo =  150  | '105';       # yields 255\n$foo = '150' | '105';       # yields 255\n$foo =  150  |. 105;        # yields string '155'\n$foo = '150' |. 105;        # yields string '155'\n$foo =  150  |.'105';       # yields string '155'\n$foo = '150' |.'105';       # yields string '155'\n\n$baz = $foo &  $bar;        # both operands numeric\n$biz = $foo ^. $bar;        # both operands stringy\n\nThe assignment variants of these operators (\"&= |= ^= &.= |.= ^.=\") behave likewise under the\nfeature.\n\nIt is a fatal error if an operand contains a character whose ordinal value is above 0xFF, and\nhence  not  expressible  except in UTF-8.  The operation is performed on a non-UTF-8 copy for\nother operands encoded in UTF-8.  See \"Byte and Character Semantics\" in perlunicode.\n\nSee \"vec\" in perlfunc for information on how to manipulate individual bits in a bit vector.\n"
                },
                {
                    "name": "Integer Arithmetic",
                    "content": "By default, Perl assumes that it must do most of its arithmetic in floating  point.   But  by\nsaying\n\nuse integer;\n\nyou  may tell the compiler to use integer operations (see integer for a detailed explanation)\nfrom here to the end of the enclosing BLOCK.  An inner BLOCK may countermand this by saying\n\nno integer;\n\nwhich lasts until the end of that BLOCK.  Note  that  this  doesn't  mean  everything  is  an\ninteger, merely that Perl will use integer operations for arithmetic, comparison, and bitwise\noperators.   For example, even under \"use integer\", if you take the sqrt(2), you'll still get\n1.4142135623731 or so.\n\nUsed on numbers, the bitwise operators (\"&\" \"|\" \"^\" \"~\" \"<<\" \">>\")  always  produce  integral\nresults.   (But  see  also  \"Bitwise  String  Operators\".)   However, \"use integer\" still has\nmeaning for them.  By default, their results are interpreted as  unsigned  integers,  but  if\n\"use integer\"  is  in effect, their results are interpreted as signed integers.  For example,\n\"~0\" usually evaluates to a large integral value.  However, \"use integer; ~0\" is -1 on two's-\ncomplement machines.\n"
                },
                {
                    "name": "Floating-point Arithmetic",
                    "content": "While \"use integer\" provides integer-only arithmetic, there  is  no  analogous  mechanism  to\nprovide automatic rounding or truncation to a certain number of decimal places.  For rounding\nto  a  certain  number  of  digits,  sprintf() or printf() is usually the easiest route.  See\nperlfaq4.\n\nFloating-point numbers are only approximations  to  what  a  mathematician  would  call  real\nnumbers.   There  are  infinitely  more  reals than floats, so some corners must be cut.  For\nexample:\n\nprintf \"%.20g\\n\", 123456789123456789;\n#        produces 123456789123456784\n\nTesting for exact floating-point equality or  inequality  is  not  a  good  idea.   Here's  a\n(relatively expensive) work-around to compare whether two floating-point numbers are equal to\na  particular number of decimal places.  See Knuth, volume II, for a more robust treatment of\nthis topic.\n\nsub fpequal {\nmy ($X, $Y, $POINTS) = @;\nmy ($tX, $tY);\n$tX = sprintf(\"%.${POINTS}g\", $X);\n$tY = sprintf(\"%.${POINTS}g\", $Y);\nreturn $tX eq $tY;\n}\n\nThe POSIX module (part of the standard perl distribution)  implements  ceil(),  floor(),  and\nother  mathematical  and  trigonometric  functions.   The \"Math::Complex\" module (part of the\nstandard perl distribution) defines mathematical functions that work on both  the  reals  and\nthe  imaginary  numbers.   \"Math::Complex\" is not as efficient as POSIX, but POSIX can't work\nwith complex numbers.\n\nRounding in financial applications can have serious implications,  and  the  rounding  method\nused  should be specified precisely.  In these cases, it probably pays not to trust whichever\nsystem rounding is being used by Perl, but to instead implement  the  rounding  function  you\nneed yourself.\n"
                },
                {
                    "name": "Bigger Numbers",
                    "content": "The  standard  \"Math::BigInt\",  \"Math::BigRat\",  and \"Math::BigFloat\" modules, along with the\n\"bignum\",  \"bigint\",  and  \"bigrat\"  pragmas,  provide  variable-precision   arithmetic   and\noverloaded  operators, although they're currently pretty slow.  At the cost of some space and\nconsiderable  speed,  they  avoid  the  normal  pitfalls  associated  with  limited-precision\nrepresentations.\n\nuse 5.010;\nuse bigint;  # easy interface to Math::BigInt\n$x = 123456789123456789;\nsay $x * $x;\n+15241578780673678515622620750190521\n\nOr with rationals:\n\nuse 5.010;\nuse bigrat;\n$x = 3/22;\n$y = 4/6;\nsay \"x/y is \", $x/$y;\nsay \"x*y is \", $x*$y;\nx/y is 9/44\nx*y is 1/11\n\nSeveral modules let you calculate with unlimited or fixed precision (bound only by memory and\nCPU  time).  There are also some non-standard modules that provide faster implementations via\nexternal C libraries.\n\nHere is a short, but incomplete summary:\n\nMath::String           treat string sequences like numbers\nMath::FixedPrecision   calculate with a fixed precision\nMath::Currency         for currency calculations\nBit::Vector            manipulate bit vectors fast (uses C)\nMath::BigIntFast       Bit::Vector wrapper for big numbers\nMath::Pari             provides access to the Pari C library\nMath::Cephes           uses the external Cephes C library (no\nbig numbers)\nMath::Cephes::Fraction fractions via the Cephes library\nMath::GMP              another one using an external C library\nMath::GMPz             an alternative interface to libgmp's big ints\nMath::GMPq             an interface to libgmp's fraction numbers\nMath::GMPf             an interface to libgmp's floating point numbers\n\nChoose wisely.\n\nperl v5.38.2                                 2026-08-18                                    PERLOP(1)"
                }
            ]
        }
    },
    "summary": "perlop - Perl operators and precedence",
    "flags": [],
    "examples": [],
    "see_also": []
}