⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perldata.pod

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 POD
📖 第 1 页 / 共 3 页
字号:
Numeric literals are specified in any of the following floating point orinteger formats:    12345    12345.67    .23E-10             # a very small number    3.14_15_92          # a very important number    4_294_967_296       # underscore for legibility    0xff                # hex    0xdead_beef         # more hex       0377                # octal (only numbers, begins with 0)    0b011011            # binaryYou are allowed to use underscores (underbars) in numeric literalsbetween digits for legibility.  You could, for example, group binarydigits by threes (as for a Unix-style mode argument such as 0b110_100_100)or by fours (to represent nibbles, as in 0b1010_0110) or in other groups.X<number, literal>String literals are usually delimited by either single or doublequotes.  They work much like quotes in the standard Unix shells:double-quoted string literals are subject to backslash and variablesubstitution; single-quoted strings are not (except for C<\'> andC<\\>).  The usual C-style backslash rules apply for makingcharacters such as newline, tab, etc., as well as some more exoticforms.  See L<perlop/"Quote and Quote-like Operators"> for a list.X<string, literal>Hexadecimal, octal, or binary, representations in string literals(e.g. '0xff') are not automatically converted to their integerrepresentation.  The hex() and oct() functions make these conversionsfor you.  See L<perlfunc/hex> and L<perlfunc/oct> for more details.You can also embed newlines directly in your strings, i.e., they can endon a different line than they begin.  This is nice, but if you forgetyour trailing quote, the error will not be reported until Perl findsanother line containing the quote character, which may be much furtheron in the script.  Variable substitution inside strings is limited toscalar variables, arrays, and array or hash slices.  (In other words,names beginning with $ or @, followed by an optional bracketedexpression as a subscript.)  The following code segment prints out "Theprice is $Z<>100."X<interpolation>    $Price = '$100';	# not interpolated    print "The price is $Price.\n";	# interpolatedThere is no double interpolation in Perl, so the C<$100> is left as is.By default floating point numbers substituted inside strings use thedot (".")  as the decimal separator.  If C<use locale> is in effect,and POSIX::setlocale() has been called, the character used for thedecimal separator is affected by the LC_NUMERIC locale.See L<perllocale> and L<POSIX>.As in some shells, you can enclose the variable name in braces todisambiguate it from following alphanumerics (and underscores).You must also dothis when interpolating a variable into a string to separate thevariable name from a following double-colon or an apostrophe, sincethese would be otherwise treated as a package separator:X<interpolation>    $who = "Larry";    print PASSWD "${who}::0:0:Superuser:/:/bin/perl\n";    print "We use ${who}speak when ${who}'s here.\n";Without the braces, Perl would have looked for a $whospeak, aC<$who::0>, and a C<$who's> variable.  The last two would be the$0 and the $s variables in the (presumably) non-existent packageC<who>.In fact, an identifier within such curlies is forced to be a string,as is any simple identifier within a hash subscript.  Neither needquoting.  Our earlier example, C<$days{'Feb'}> can be written asC<$days{Feb}> and the quotes will be assumed automatically.  Butanything more complicated in the subscript will be interpreted as anexpression.  This means for example that C<$version{2.0}++> isequivalent to C<$version{2}++>, not to C<$version{'2.0'}++>.=head3 Version StringsX<version string> X<vstring> X<v-string>B<Note:> Version Strings (v-strings) have been deprecated.  They willbe removed in some future release after Perl 5.8.1.  The marginalbenefits of v-strings were greatly outweighed by the potential forSurprise and Confusion.A literal of the form C<v1.20.300.4000> is parsed as a string composedof characters with the specified ordinals.  This form, known asv-strings, provides an alternative, more readable way to constructstrings, rather than use the somewhat less readable interpolation formC<"\x{1}\x{14}\x{12c}\x{fa0}">.  This is useful for representingUnicode strings, and for comparing version "numbers" using the stringcomparison operators, C<cmp>, C<gt>, C<lt> etc.  If there are two ormore dots in the literal, the leading C<v> may be omitted.    print v9786;              # prints SMILEY, "\x{263a}"    print v102.111.111;       # prints "foo"    print 102.111.111;        # sameSuch literals are accepted by both C<require> and C<use> fordoing a version check.  Note that using the v-strings for IPv4addresses is not portable unless you also use theinet_aton()/inet_ntoa() routines of the Socket package.Note that since Perl 5.8.1 the single-number v-strings (like C<v65>)are not v-strings before the C<< => >> operator (which is usually usedto separate a hash key from a hash value), instead they are interpretedas literal strings ('v65').  They were v-strings from Perl 5.6.0 toPerl 5.8.0, but that caused more confusion and breakage than good.Multi-number v-strings like C<v65.66> and C<65.66.67> continue tobe v-strings always.=head3 Special LiteralsX<special literal> X<__END__> X<__DATA__> X<END> X<DATA>X<end> X<data> X<^D> X<^Z>The special literals __FILE__, __LINE__, and __PACKAGE__represent the current filename, line number, and package name at thatpoint in your program.  They may be used only as separate tokens; theywill not be interpolated into strings.  If there is no current package(due to an empty C<package;> directive), __PACKAGE__ is the undefinedvalue.X<__FILE__> X<__LINE__> X<__PACKAGE__> X<line> X<file> X<package>The two control characters ^D and ^Z, and the tokens __END__ and __DATA__may be used to indicate the logical end of the script before the actualend of file.  Any following text is ignored.Text after __DATA__ but may be read via the filehandle C<PACKNAME::DATA>,where C<PACKNAME> is the package that was current when the __DATA__token was encountered.  The filehandle is left open pointing to thecontents after __DATA__.  It is the program's responsibility toC<close DATA> when it is done reading from it.  For compatibility witholder scripts written before __DATA__ was introduced, __END__ behaveslike __DATA__ in the top level script (but not in files loaded withC<require> or C<do>) and leaves the remaining contents of thefile accessible via C<main::DATA>.See L<SelfLoader> for more description of __DATA__, andan example of its use.  Note that you cannot read from the DATAfilehandle in a BEGIN block: the BEGIN block is executed as soonas it is seen (during compilation), at which point the corresponding__DATA__ (or __END__) token has not yet been seen.=head3 BarewordsX<bareword>A word that has no other interpretation in the grammar willbe treated as if it were a quoted string.  These are known as"barewords".  As with filehandles and labels, a bareword that consistsentirely of lowercase letters risks conflict with future reservedwords, and if you use the C<use warnings> pragma or the B<-w> switch, Perl will warn you about anysuch words.  Some people may wish to outlaw barewords entirely.  If yousay    use strict 'subs';then any bareword that would NOT be interpreted as a subroutine callproduces a compile-time error instead.  The restriction lasts to theend of the enclosing block.  An inner block may countermand thisby saying C<no strict 'subs'>.=head3 Array Joining DelimiterX<array, interpolation> X<interpolation, array> X<$">Arrays and slices are interpolated into double-quoted stringsby joining the elements with the delimiter specified in the C<$">variable (C<$LIST_SEPARATOR> if "use English;" is specified), space by default.  The following are equivalent:    $temp = join($", @ARGV);    system "echo $temp";    system "echo @ARGV";Within search patterns (which also undergo double-quotish substitution)there is an unfortunate ambiguity:  Is C</$foo[bar]/> to be interpreted asC</${foo}[bar]/> (where C<[bar]> is a character class for the regularexpression) or as C</${foo[bar]}/> (where C<[bar]> is the subscript to array@foo)?  If @foo doesn't otherwise exist, then it's obviously acharacter class.  If @foo exists, Perl takes a good guess about C<[bar]>,and is almost always right.  If it does guess wrong, or if you're justplain paranoid, you can force the correct interpretation with curlybraces as above.If you're looking for the information on how to use here-documents,which used to be here, that's been moved toL<perlop/Quote and Quote-like Operators>.=head2 List value constructorsX<list>List values are denoted by separating individual values by commas(and enclosing the list in parentheses where precedence requires it):    (LIST)In a context not requiring a list value, the value of what appearsto be a list literal is simply the value of the final element, aswith the C comma operator.  For example,    @foo = ('cc', '-E', $bar);assigns the entire list value to array @foo, but    $foo = ('cc', '-E', $bar);assigns the value of variable $bar to the scalar variable $foo.Note that the value of an actual array in scalar context is thelength of the array; the following assigns the value 3 to $foo:    @foo = ('cc', '-E', $bar);    $foo = @foo;                # $foo gets 3You may have an optional comma before the closing parenthesis of alist literal, so that you can say:    @foo = (        1,        2,        3,    );To use a here-document to assign an array, one line per element,you might use an approach like this:    @sauces = <<End_Lines =~ m/(\S.*\S)/g;        normal tomato        spicy tomato        green chile        pesto        white wine    End_LinesLISTs do automatic interpolation of sublists.  That is, when a LIST isevaluated, each element of the list is evaluated in list context, andthe resulting list value is interpolated into LIST just as if eachindividual element were a member of LIST.  Thus arrays and hashes lose theiridentity in a LIST--the list    (@foo,@bar,&SomeSub,%glarch)contains all the elements of @foo followed by all the elements of @bar,followed by all the elements returned by the subroutine named SomeSub called in list context, followed by the key/value pairs of %glarch.To make a list reference that does I<NOT> interpolate, see L<perlref>.The null list is represented by ().  Interpolating it in a listhas no effect.  Thus ((),(),()) is equivalent to ().  Similarly,interpolating an array with no elements is the same as if noarray had been interpolated at that point.This interpolation combines with the facts that the openingand closing parentheses are optional (except when necessary forprecedence) and lists may end with an optional comma to mean thatmultiple commas within lists are legal syntax. The list C<1,,3> is aconcatenation of two lists, C<1,> and C<3>, the first of which endswith that optional comma.  C<1,,3> is C<(1,),(3)> is C<1,3> (Andsimilarly for C<1,,,3> is C<(1,),(,),3> is C<1,3> and so on.)  Not thatwe'd advise you to use this obfuscation.A list value may also be subscripted like a normal array.  You mustput the list in parentheses to avoid ambiguity.  For example:    # Stat returns list value.    $time = (stat($file))[8];    # SYNTAX ERROR HERE.    $time = stat($file)[8];  # OOPS, FORGOT PARENTHESES    # Find a hex digit.    $hexdigit = ('a','b','c','d','e','f')[$digit-10];    # A "reverse comma operator".    return (pop(@foo),pop(@foo))[0];Lists may be assigned to only when each element of the listis itself legal to assign to:    ($a, $b, $c) = (1, 2, 3);    ($map{'red'}, $map{'blue'}, $map{'green'}) = (0x00f, 0x0f0, 0xf00);An exception to this is that you may assign to C<undef> in a list.This is useful for throwing away some of the return values of afunction:

⌨️ 快捷键说明

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