perlop.1

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· 1 代码 · 共 1,599 行 · 第 1/5 页

1
1,599
字号
.Vb 4\&    print ++($foo = \*(Aq99\*(Aq);      # prints \*(Aq100\*(Aq\&    print ++($foo = \*(Aqa0\*(Aq);      # prints \*(Aqa1\*(Aq\&    print ++($foo = \*(AqAz\*(Aq);      # prints \*(AqBa\*(Aq\&    print ++($foo = \*(Aqzz\*(Aq);      # prints \*(Aqaaa\*(Aq.Ve.PP\&\f(CW\*(C`undef\*(C'\fR is always treated as numeric, and in particular is changedto \f(CW0\fR before incrementing (so that a post-increment of an undef valuewill return \f(CW0\fR rather than \f(CW\*(C`undef\*(C'\fR)..PPThe auto-decrement operator is not magical..Sh "Exponentiation".IX Xref "** exponentiation power".IX Subsection "Exponentiation"Binary \*(L"**\*(R" is the exponentiation operator.  It binds even moretightly than unary minus, so \-2**4 is \-(2**4), not (\-2)**4. (This isimplemented using C's \fIpow\fR\|(3) function, which actually works on doublesinternally.).Sh "Symbolic Unary Operators".IX Xref "unary operator operator, unary".IX Subsection "Symbolic Unary Operators"Unary \*(L"!\*(R" performs logical negation, i.e., \*(L"not\*(R".  See also \f(CW\*(C`not\*(C'\fR for a lowerprecedence version of this..IX Xref "!".PPUnary \*(L"\-\*(R" performs arithmetic negation if the operand is numeric.  Ifthe operand is an identifier, a string consisting of a minus signconcatenated with the identifier is returned.  Otherwise, if the stringstarts with a plus or minus, a string starting with the opposite signis returned.  One effect of these rules is that \-bareword is equivalentto the string \*(L"\-bareword\*(R".  If, however, the string begins with anon-alphabetic character (excluding \*(L"+\*(R" or \*(L"\-\*(R"), Perl will attempt to convertthe string to a numeric and the arithmetic negation is performed. If thestring cannot be cleanly converted to a numeric, Perl will give the warning\&\fBArgument \*(L"the string\*(R" isn't numeric in negation (\-) at ...\fR..IX Xref "- negation, arithmetic".PPUnary \*(L"~\*(R" performs bitwise negation, i.e., 1's complement.  Forexample, \f(CW\*(C`0666 & ~027\*(C'\fR is 0640.  (See also \*(L"Integer Arithmetic\*(R" and\&\*(L"Bitwise String Operators\*(R".)  Note that the width of the result isplatform-dependent: ~0 is 32 bits wide on a 32\-bit platform, but 64bits wide on a 64\-bit platform, so if you are expecting a certain bitwidth, remember to use the & operator to mask off the excess bits..IX Xref "~ negation, binary".PPUnary \*(L"+\*(R" has no effect whatsoever, even on strings.  It is usefulsyntactically for separating a function name from a parenthesized expressionthat would otherwise be interpreted as the complete list of functionarguments.  (See examples above under \*(L"Terms and List Operators (Leftward)\*(R".).IX Xref "+".PPUnary \*(L"\e\*(R" creates a reference to whatever follows it.  See perlreftutand perlref.  Do not confuse this behavior with the behavior ofbackslash within a string, although both forms do convey the notionof protecting the next thing from interpolation..IX Xref "\e reference backslash".Sh "Binding Operators".IX Xref "binding operator, binding =~ !~".IX Subsection "Binding Operators"Binary \*(L"=~\*(R" binds a scalar expression to a pattern match.  Certain operationssearch or modify the string \f(CW$_\fR by default.  This operator makes that kindof operation work on some other string.  The right argument is a searchpattern, substitution, or transliteration.  The left argument is what issupposed to be searched, substituted, or transliterated instead of the default\&\f(CW$_\fR.  When used in scalar context, the return value generally indicates thesuccess of the operation.  Behavior in list context depends on the particularoperator.  See \*(L"Regexp Quote-Like Operators\*(R" for details andperlretut for examples using these operators..PPIf the right argument is an expression rather than a search pattern,substitution, or transliteration, it is interpreted as a search pattern at runtime. Note that this means that its contents will be interpolated twice, so.PP.Vb 1\&  \*(Aq\e\e\*(Aq =~ q\*(Aq\e\e\*(Aq;.Ve.PPis not ok, as the regex engine will end up trying to compile thepattern \f(CW\*(C`\e\*(C'\fR, which it will consider a syntax error..PPBinary \*(L"!~\*(R" is just like \*(L"=~\*(R" except the return value is negated inthe logical sense..Sh "Multiplicative Operators".IX Xref "operator, multiplicative".IX Subsection "Multiplicative Operators"Binary \*(L"*\*(R" multiplies two numbers..IX Xref "*".PPBinary \*(L"/\*(R" divides two numbers..IX Xref "slash".PPBinary \*(L"%\*(R" computes the modulus of two numbers.  Given integeroperands \f(CW$a\fR and \f(CW$b\fR: If \f(CW$b\fR is positive, then \f(CW\*(C`$a % $b\*(C'\fR is\&\f(CW$a\fR minus the largest multiple of \f(CW$b\fR that is not greater than\&\f(CW$a\fR.  If \f(CW$b\fR is negative, then \f(CW\*(C`$a % $b\*(C'\fR is \f(CW$a\fR minus thesmallest multiple of \f(CW$b\fR that is not less than \f(CW$a\fR (i.e. theresult will be less than or equal to zero).  If the operands\&\f(CW$a\fR and \f(CW$b\fR are floating point values and the absolute value of\&\f(CW$b\fR (that is \f(CW\*(C`abs($b)\*(C'\fR) is less than \f(CW\*(C`(UV_MAX + 1)\*(C'\fR, onlythe integer portion of \f(CW$a\fR and \f(CW$b\fR will be used in the operation(Note: here \f(CW\*(C`UV_MAX\*(C'\fR means the maximum of the unsigned integer type).If the absolute value of the right operand (\f(CW\*(C`abs($b)\*(C'\fR) is greater thanor equal to \f(CW\*(C`(UV_MAX + 1)\*(C'\fR, \*(L"%\*(R" computes the floating-point remainder\&\f(CW$r\fR in the equation \f(CW\*(C`($r = $a \- $i*$b)\*(C'\fR where \f(CW$i\fR is a certaininteger that makes \f(CW$r\fR should have the same sign as the right operand\&\f(CW$b\fR (\fBnot\fR as the left operand \f(CW$a\fR like C function \f(CW\*(C`fmod()\*(C'\fR)and the absolute value less than that of \f(CW$b\fR.Note that when \f(CW\*(C`use integer\*(C'\fR is in scope, \*(L"%\*(R" gives you direct accessto the modulus operator as implemented by your C compiler.  Thisoperator is not as well defined for negative operands, but it willexecute faster..IX Xref "% remainder modulus mod".PPBinary \*(L"x\*(R" is the repetition operator.  In scalar context or if the leftoperand is not enclosed in parentheses, it returns a string consistingof the left operand repeated the number of times specified by the rightoperand.  In list context, if the left operand is enclosed inparentheses or is a list formed by \f(CW\*(C`qw/STRING/\*(C'\fR, it repeats the list.If the right operand is zero or negative, it returns an empty stringor an empty list, depending on the context..IX Xref "x".PP.Vb 1\&    print \*(Aq\-\*(Aq x 80;             # print row of dashes\&\&    print "\et" x ($tab/8), \*(Aq \*(Aq x ($tab%8);      # tab over\&\&    @ones = (1) x 80;           # a list of 80 1\*(Aqs\&    @ones = (5) x @ones;        # set all elements to 5.Ve.Sh "Additive Operators".IX Xref "operator, additive".IX Subsection "Additive Operators"Binary \*(L"+\*(R" returns the sum of two numbers..IX Xref "+".PPBinary \*(L"\-\*(R" returns the difference of two numbers..IX Xref "-".PPBinary \*(L".\*(R" concatenates two strings..IX Xref "string, concatenation concatenation cat concat concatenate .".Sh "Shift Operators".IX Xref "shift operator operator, shift << >> right shift left shift bitwise shift shl shr shift, right shift, left".IX Subsection "Shift Operators"Binary \*(L"<<\*(R" returns the value of its left argument shifted left by thenumber of bits specified by the right argument.  Arguments should beintegers.  (See also \*(L"Integer Arithmetic\*(R".).PPBinary \*(L">>\*(R" returns the value of its left argument shifted right bythe number of bits specified by the right argument.  Arguments shouldbe integers.  (See also \*(L"Integer Arithmetic\*(R".).PPNote that both \*(L"<<\*(R" and \*(L">>\*(R" in Perl are implemented directly using\&\*(L"<<\*(R" and \*(L">>\*(R" in C.  If \f(CW\*(C`use integer\*(C'\fR (see \*(L"Integer Arithmetic\*(R") isin force then signed C integers are used, else unsigned C integers areused.  Either way, the implementation isn't going to generate resultslarger than the size of the integer type Perl was built with (32 bitsor 64 bits)..PPThe result of overflowing the range of the integers is undefinedbecause it is undefined also in C.  In other words, using 32\-bitintegers, \f(CW\*(C`1 << 32\*(C'\fR is undefined.  Shifting by a negative numberof bits is also undefined..Sh "Named Unary Operators".IX Xref "operator, named unary".IX Subsection "Named Unary Operators"The various named unary operators are treated as functions with oneargument, with optional parentheses..PPIf any list operator (\fIprint()\fR, etc.) or any unary operator (\fIchdir()\fR, etc.)is followed by a left parenthesis as the next token, the operator andarguments within parentheses are taken to be of highest precedence,just like a normal function call.  For example,because named unary operators are higher precedence than ||:.PP.Vb 4\&    chdir $foo    || die;       # (chdir $foo) || die\&    chdir($foo)   || die;       # (chdir $foo) || die\&    chdir ($foo)  || die;       # (chdir $foo) || die\&    chdir +($foo) || die;       # (chdir $foo) || die.Ve.PPbut, because * is higher precedence than named operators:.PP.Vb 4\&    chdir $foo * 20;    # chdir ($foo * 20)\&    chdir($foo) * 20;   # (chdir $foo) * 20\&    chdir ($foo) * 20;  # (chdir $foo) * 20\&    chdir +($foo) * 20; # chdir ($foo * 20)\&\&    rand 10 * 20;       # rand (10 * 20)\&    rand(10) * 20;      # (rand 10) * 20\&    rand (10) * 20;     # (rand 10) * 20\&    rand +(10) * 20;    # rand (10 * 20).Ve.PPRegarding precedence, the filetest operators, like \f(CW\*(C`\-f\*(C'\fR, \f(CW\*(C`\-M\*(C'\fR, etc. aretreated like named unary operators, but they don't follow this functionalparenthesis rule.  That means, for example, that \f(CW\*(C`\-f($file).".bak"\*(C'\fR isequivalent to \f(CW\*(C`\-f "$file.bak"\*(C'\fR..IX Xref "-X filetest operator, filetest".PPSee also \*(L"Terms and List Operators (Leftward)\*(R"..Sh "Relational Operators".IX Xref "relational operator operator, relational".IX Subsection "Relational Operators"Binary \*(L"<\*(R" returns true if the left argument is numerically less thanthe right argument..IX Xref "<".PPBinary \*(L">\*(R" returns true if the left argument is numerically greaterthan the right argument..IX Xref ">".PPBinary \*(L"<=\*(R" returns true if the left argument is numerically less thanor equal to the right argument..IX Xref "<=".PPBinary \*(L">=\*(R" returns true if the left argument is numerically greaterthan or equal to the right argument..IX Xref ">=".PPBinary \*(L"lt\*(R" returns true if the left argument is stringwise less thanthe right argument..IX Xref "lt".PPBinary \*(L"gt\*(R" returns true if the left argument is stringwise greaterthan the right argument..IX Xref "gt".PPBinary \*(L"le\*(R" returns true if the left argument is stringwise less thanor equal to the right argument..IX Xref "le".PPBinary \*(L"ge\*(R" returns true if the left argument is stringwise greaterthan or equal to the right argument..IX Xref "ge".Sh "Equality Operators".IX Xref "equality equal equals operator, equality".IX Subsection "Equality Operators"Binary \*(L"==\*(R" returns true if the left argument is numerically equal tothe right argument..IX Xref "==".PPBinary \*(L"!=\*(R" returns true if the left argument is numerically not equalto the right argument..IX Xref "!=".PPBinary \*(L"<=>\*(R" returns \-1, 0, or 1 depending on whether the leftargument is numerically less than, equal to, or greater than the rightargument.  If your platform supports NaNs (not-a-numbers) as numericvalues, using them with \*(L"<=>\*(R" returns undef.  NaN is not \*(L"<\*(R", \*(L"==\*(R", \*(L">\*(R",\&\*(L"<=\*(R" or \*(L">=\*(R" anything (even NaN), so those 5 return false. NaN != NaNreturns true, as does NaN != anything else. If your platform doesn'tsupport NaNs then NaN is just a string with numeric value 0..IX Xref "<=> spaceship".PP.Vb 2\&    perl \-le \*(Aq$a = "NaN"; print "No NaN support here" if $a == $a\*(Aq\&    perl \-le \*(Aq$a = "NaN"; print "NaN support here" if $a != $a\*(Aq.Ve.PPBinary \*(L"eq\*(R" returns true if the left argument is stringwise equal tothe right argument..IX Xref "eq".PPBinary \*(L"ne\*(R" returns true if the left argument is stringwise not equalto the right argument..IX Xref "ne".PPBinary \*(L"cmp\*(R" returns \-1, 0, or 1 depending on whether the leftargument is stringwise less than, equal to, or greater than the rightargument..IX Xref "cmp".PPBinary \*(L"~~\*(R" does a smart match between its arguments. Smart matchingis described in \*(L"Smart matching in detail\*(R" in perlsyn.This operator is only available if you enable the \*(L"~~\*(R" feature:see feature for more information..IX Xref "~~".PP\&\*(L"lt\*(R", \*(L"le\*(R", \*(L"ge\*(R", \*(L"gt\*(R" and \*(L"cmp\*(R" use the collation (sort) order specifiedby the current locale if \f(CW\*(C`use locale\*(C'\fR is in effect.  See perllocale..Sh "Bitwise And".IX Xref "operator, bitwise, and bitwise and &".IX Subsection "Bitwise And"Binary \*(L"&\*(R" returns its operands ANDed together bit by bit.(See also \*(L"Integer Arithmetic\*(R" and \*(L"Bitwise String Operators\*(R".).PPNote that \*(L"&\*(R" has lower priority than relational operators, so for examplethe brackets are essential in a test like.PP.Vb 1\&        print "Even\en" if ($x & 1) == 0;.Ve.Sh "Bitwise Or and Exclusive Or".IX Xref "operator, bitwise, or bitwise or | operator, bitwise, xor bitwise xor ^".IX Subsection "Bitwise Or and Exclusive Or"Binary \*(L"|\*(R" returns its operands ORed together bit by bit.(See also \*(L"Integer Arithmetic\*(R" and \*(L"Bitwise String Operators\*(R".).PPBinary \*(L"^\*(R" returns its operands XORed together bit by bit.(See also \*(L"Integer Arithmetic\*(R" and \*(L"Bitwise String Operators\*(R".).PPNote that \*(L"|\*(R" and \*(L"^\*(R" have lower priority than relational operators, sofor example the brackets are essential in a test like.PP.Vb 1\&        print "false\en" if (8 | 2) != 10;.Ve.Sh "C\-style Logical And".IX Xref "&& logical and operator, logical, and".IX Subsection "C-style Logical And"Binary \*(L"&&\*(R" performs a short-circuit logical \s-1AND\s0 operation.  That is,if the left operand is false, the right operand is not even evaluated.Scalar or list context propagates down to the right operand if itis evaluated..Sh "C\-style Logical Or".IX Xref "|| operator, logical, or"

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?